Version: 0.5.0


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).

type move is int * int
type register is big_map (address, move)

Be aware that a big_map cannot appear inside another big_map.

type bool
type bytes
type contract('parameter)

A typed contract.

Use unit as parameter 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 move is int * int
type register is map (address, move)
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
function is_nat: int -> option(nat)

Convert an int to a nat if possible.

Note that Michelson.is_nat is deprecated. Please use is_nat instead.

function abs: int -> nat

Cast an int to nat.

function int: nat -> int

Cast an nat to int.

const unit: unit

A helper to create a unit.

function failwith : '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.

function main (const p : int; const s : unit) : list (operation) * unit is
block {
if p > 10 then failwith ("Failure.") else skip
with ((nil : list (operation)), s)
function assert : bool -> unit

Check if a certain condition has been met. If not the contract will fail.

function ediv : int -> int -> option (int * nat)
function ediv : mutez -> nat -> option (mutez * mutez)
function ediv : mutez -> mutez -> option (nat * mutez)
function ediv : nat -> 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).