Skip to main content

Archetype contract

An archetype contract starts with the archetype keyword followed by a contract identifier.

For example:

archetype escrow

/* ... */

Parameters

A contract may have parameters. A parameter value is not in the source code and is provided at deployment (origination) time. For example, the address of the contract owner is typically a contract parameter.

Variable

By default, a contract parameter is an element of the contract storage. It is defined by an identifier and a type. The list of parameters follows the contract's identifier between parenthesis and separated by comma.

For example:

archetype escrow(seller : address, buyer : address)

/* ... */

The seller and buyer addresses then need to be set at deployment time with the completium CLI's deploy command; for example:

completium-cli deploy escrow.arl --parameters '{ "seller" : "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb", "buyer" : "tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6" }'

The value of a contract parameter may be modified by assignment instructions in entrypoints.

Constant

If a contract parameter is not meant to be modified, nor to appear in the storage, it may be declared const. Its value, provided at deployment time as for variable parameter, is then inlined, that it replaces each occurence of the parmeter.

For example, the declaration of the FA 1.2 token contract:

archetype fa1_2(const initial_holder : address, const total_supply : nat)
with metadata ""

/* ... */

Metadata

The TZIP-16 specifies the standard contract's metadata as a storage map. It is declared with with metadata in contract declaration followed by intitial URL to metadata file:

archetype my_token with metadata ""

This adds the metadata map to the storage.

A metadata template is provided here.