Skip to main content
Version: 2.0.0

Smart Contracts

Smart Contracts in General

A smart contract is a self-executing program that automates the actions required in a digital agreement. Once completed, the transactions are trackable and irreversible. Smart contracts permit trusted transactions and agreements among disparate, anonymous parties without the need for a central authority, legal system, or external enforcement mechanism.

Casper Smart Contracts

Casper smart contracts can be implemented in any programming language that compiles to Wasm, which can be installed and executed on-chain using transactions. Most documentation examples and the Casper system contracts are written in Rust. You can find a guide to writing a simple, smart contract in Rust here.

Session Code

Session code is the simplest logic one can execute on a Casper network. It is essential because it is often used to trigger contract logic stored on-chain. Entry points in a contract provide access to the contract code installed in global state. Either session code or another smart contract may call these entry points. Understand when you would use session code over contract code here.

Factory Pattern

From node version 2.0, Casper networks provide host-side support for the factory implementations. When the APIs were updated to support this pattern, the focus was on seamless integration with existing Wasm on the Casper blockchain. Contracts already installed in global state will not be affected by these updates. The corresponding Casper Enhancement Proposal provides additional details. Also, you can learn to write a simple contract with factory entry points by following the The Factory Pattern developer guide.

Further Reading