Skip to main content

Top-Level

These types and functions are available without any needed prefix.

cameligo

type address

jsligo

type address

An untyped address which can refer to a smart contract or account.

cameligo

type ('key, 'value) big_map

jsligo

type big_map <'key, 'value>

cameligo

The type of a big map from values of type key to values of type value is (key, value) big_map.

type move = int * int
type register = (address, move) big_map
jsligo

The type of a big map from values of type key to values of type value is big_map<key, value>.

type move = [int, int];
type register = big_map<address, move>;

Be aware that a big_map cannot appear inside another big_map.

cameligo

type bool

jsligo

type bool

cameligo

type bytes

jsligo

type bytes

cameligo

type 'param contract

jsligo

type contract<'param>

A typed contract.

Use unit as param to indicate an implicit account.

cameligo

type chain_id

jsligo

type chain_id

The identifier of a chain, used to indicate test or main chains.

cameligo

type int

jsligo

type int

An integer.

The only size limit to integers is gas.

cameligo

type key

jsligo

type key

A public cryptographic key.

cameligo

type key_hash

jsligo

type key_hash

The hash of a public cryptographic key.

cameligo

type 't list

jsligo

type list<'t>

A sequence of elements of the same type.

cameligo

type ('key, 'value) map

jsligo

type map <'key, 'value>

cameligo

The type of a map from values of type key to values of type value is (key, value) map.

type move = int * int
type register = (address, move) map
jsligo

The type of a map from values of type key to values of type value is map <key, value>.

type move = [int, int];
type register = map <address, move>;
cameligo

type nat

jsligo

type nat

A natural number.

The only size limit to natural numbers is gas.

cameligo

type operation

jsligo

type operation

An operation emitted by the contract

cameligo

type 'value set

jsligo

type set<'value>

cameligo

type signature

jsligo

type signature

A cryptographic signature.

cameligo

type string

jsligo

type string

A sequence of characters.

cameligo

type tez

jsligo

type tez

A specific type for tokens.

cameligo

type timestamp

jsligo

type timestamp

A date in the real world.

cameligo

type chest

jsligo

type chest

A timelocked chest.

cameligo

type chest_key

jsligo

type chest_key

A key to open a timelocked chest.

cameligo

type unit

jsligo

type unit

cameligo

val is_nat: int -> nat option

jsligo

let is_nat: (i: int) => option<nat>

Convert an int to a nat if possible.

cameligo

val abs: int -> nat

jsligo

let abs: (i: int) => nat

Cast an int to nat.

cameligo

val int: nat -> int

jsligo

let int: (n: nat) => int

Cast an nat to int.

cameligo

val unit: unit

jsligo

let unit: unit

A helper to create a unit.

cameligo

val failwith : 'a -> 'b

jsligo

let failwith: (message: 'a) => 'b

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.

cameligo
let main (p : int) (_s : unit) : operation list * unit =
if p > 10 then failwith "Failure." else [], ()
jsligo
let main = (p: int, s: unit): [list<operation>, unit] => {
if (p > 10) { failwith ("Failure."); } else return [list([]), []];
};
cameligo

val assert : bool -> unit

jsligo

let assert: (condition: bool) => unit

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

cameligo

val ediv : int -> int -> (int * nat) option

cameligo

val ediv : mutez -> nat -> (mutez * mutez) option

cameligo

val ediv : mutez -> mutez -> (nat * mutez) option

cameligo

val ediv : nat -> nat -> (nat * nat) option

jsligo

let ediv: (value: int, divided_by: int) => option<[int, nat]>

jsligo

let ediv: (value: mutez, divided_by: nat) => option<[mutez, mutez]>

jsligo

let ediv: (value: mutez, divided_by: mutez) => option<[nat, mutez]>

jsligo

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

cameligo

val ignore : 'a -> unit

jsligo

let ignore: (value: 'a) => 'unit

Ignores a value, it can be an alternative to _ prefixed variables.

cameligo

type 'n sapling_state

cameligo

type 'n sapling_transaction

cameligo

type 'v ticket

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.

cameligo
type va = int
type my_ticket = va ticket