Top-Level
These types and functions are available without any needed prefix.
type address
An untyped address which can refer to a smart contract or account.
type big_map <'key, 'value>
The type of a big map from values of type key
to
values of type value
is big_map<key, value>
.
Be aware that a big_map
cannot appear inside another big_map
.
type bool
type bytes
type contract<'param>
A typed contract.
Use unit
as param
to indicate an implicit account.
type chain_id
The identifier of a chain, used to indicate test or main chains.
type int
An integer.
The only size limit to integers is gas.
type key
A public cryptographic key.
type key_hash
The hash of a public cryptographic key.
type list<'t>
A sequence of elements of the same type.
type map <'key, 'value>
The type of a map from values of type key
to
values of type value
is map <key, value>
.
type nat
A natural number.
The only size limit to natural numbers is gas.
type operation
An operation emitted by the contract
type set<'value>
type signature
A cryptographic signature.
type string
A sequence of characters.
type tez
A specific type for tokens.
type timestamp
A date in the real world.
type unit
let is_nat: (i: int) => option<nat>
Convert an int
to a nat
if possible.
let abs: (i: int) => nat
Cast an int
to nat
.
let int: (n: nat) => int
Cast an nat
to int
.
let unit: unit
A helper to create a unit.
let failwith: (message: 'a) => unit
Cause the contract to fail with an error message or integer. Other types are not supported at the moment.
Using this currently requires in general a type annotation on the
failwith
call.
let assert: (condition: bool) => unit
Check if a certain condition has been met. If not the contract will fail.
let ediv: (value: int, divided_by: int) => option<[int, nat]>
let ediv: (value: mutez, divided_by: nat) => option<[mutez, mutez]>
let ediv: (value: mutez, divided_by: mutez) => option<[nat, mutez]>
let ediv: (value: nat, divided_by: nat) => option<[nat, nat]>
Compiles to Michelson EDIV
, one operation to get both the quotient and remainder of a division. ediv x y
returns None if y
is zero, otherwise returns Some (quotient, remainder)
such that x = (quotient * y) + remainder
and 0 <= remainder < abs(y)
.
Edo protocol introduced the following ticket type. Follow this wallet example for an example of correct usage (it goes with its builder). This article might also be useful.
Note that a variable containing a ticket can only be used once (they are not DUP
-able).
The ticket type can be defined over a comparable type 'v
.
'v
being the type of the value used to identify a given ticket.