Contract structure
A contract is composed by three blocks:
field declarations
constructor (optional)
entries and views
Fields
A field represents a named value in the contract storage:
Constructor
A constructor is an optional block, which allows to build an initial storage value for the contract; if defined, all storage field should be assigned in the body. The constructor could receive parameters, used to compute the initial storage: this is useful when a contract want to instantiate another contract using createContract.
Entries and Views
Entries and views defined the callable functionalities of the smart contract; they have a name and they could receive parameters.
An entry body is essentially an expression which always evalutes to an operation list. Entry body expression can modify the contract storage using particular expression with side effects (assignments and type specific modifiers).
Views instead, are syntatic sugar for the callback pattern and they're translated to normal entries in the interal AST. Views have a custom return type
Which is equivalent to:
Last updated