variablesdeclare global variables. A constant value cannot be modified in the contract's actions.
statesdeclares contract's possible states. It is then possible to use transitions to change the contract states (see below)
initialis used to declare the initial state value of the contract.
actiondeclares an entry point of the contract. An action has the following sections:
specification(optional) to provide the post conditions the action is supposed to have
accept transfer(optional) to specify that transfer of tez is accepted
called by(optional) to declare which role may call this action
require(optional) to list the necessary conditions for the action to be executed
failif(optional)to list the conditions which prevent from execution
effectis the code to execute by the action
transitiondeclares an entry point of the contract that changes the state of the contract. A transition has the same sections as an action (except
effect, see above) plus:
fromto specify the states the transition starts from
toto specify the states after the transition
when(optional) to specify the transition condition
with effectto specify the effect of the transition
to ... when .... with effect ...sections in a transition. It is possible to specify a list of original states for the transition to start from:
bool: boolean values
int: integer values
rational: floating value that can be expressed as the quotient or fraction of two integers
address: account address
role: an address that can be used in action's called by section
date: date values
duration: duration values (in second, minute, hour, day, week)
string: string of characters
tez: Tezos currency
bytes: bytes sequence
*declares a tuple made of other types.
optiondeclares an option of type.
listdeclares a list of any type (builtin or composed)
assetdeclares a collection of asset and the data an asset is composed of. For example the following declares a collection of real estates described by an address, a location and an owner:
enumdeclares an enumeration value. It is read with a
match ... withcommand (see below).
contractdeclares the signature of another existing contract to call in actions.
collectiondeclares an asset field as a collection of another asset.
partitiondeclares an asset field as a collection of another asset. The difference with
collectionis that a partition ensures at compilation that every partitioned asset (i.e. element of the partition) belongs to one and only partitioning asset.
remove(see operation below). This has to be done via a partition field:
vardeclares a local variable with its value. While possible, it is not necessary to declare the type a local variable. Local variables' identifier must be unique (no name capture in Archetype).
:=enables to assign a new value to a global or local variable.
/=enable to respectively increment and decrement an integer variable (local or global).
addenables to add an asset to an asset collection. It fails if the asset key is already present in the collection.
updateenables to update an existing asset; it takes as arguments the id of the asset to update and the list of effects on the asset. It fails if the id is not present in the asset collection.
addupdateis similar to update except that it adds the asset if its identifier is not present in the collection.
removeremoves a an asset from its collection.
removeifenables removing assets under a condition.
clearclears an asset collection.
if then elseare the conditional branchings instructions.
match ... with ... endFIXME
for in do doneiterates over a collection.
iter to do doneiterates over a sequence of integer values (starting from 1).
transfertransfers an amount of tez to an address or a contract.
contractkeyword presented above, it is possible to transfer to a contract and call an entry point. In the example below, the entry point
cis called and
failaborts the execution. It prevents from deploying the contract on the blockchain. As a consequence the storage is left unchanged when executed.
failiffail if the argument condition is respectively false and true.
require(t)is sugar for
if t then fail("").
andoperator of logical conjunction
oroperator of logical disjunction
notoperator of logical negation
prependadds an element to a list at the first position.