Skip to main content
Version: 1.4.0

toplevel

type string

type bytes

type int

type nat

type unit

type operation

type mav

type address

type signature

type key

type key_hash

type timestamp

type list

type big_map

type map

type set

type contract

type michelson_or

type michelson_pair

type chain_id

type baker_hash

type pvss_key

type sapling_state

type sapling_transaction

type baker_operation

type bls12_381_g1

type bls12_381_g2

type bls12_381_fr

type never

type ticket

type chest

type chest_key

type external_ediv

type external_and

type external_or

type external_xor

type external_lsl

type external_lsr

type external_bytes

type entrypoint<param, storage> = (_: param) => (_: storage) => [list<operation>, storage]

Type of entrypoints

type bool = bool

Type of the booleans. Note: Values true and false are predefined constants.

type option<a> = option<a>

Type of optional values. They are useful, for example, when a function can fail, but the caller wants to be able to handle the failure, which is then denoted by the result None(). Note: Assertions and failwith do not allow handling.

let unit: unit

Unit type. It is useful for typing side-effects, for example failures, some iterators and implicit accounts.

let ignore: <a>(_: a) => unit

The call ignore(v) evaluates v and ignores its value, returning instead the unit value. This is useful when the argument of ignore performs side-effects.

let curry: <a, b, c>(_: (_: [a, b]) => c) => (_: a) => (_: b) => c

The call curry(f,x,y) has the same value as f(x,y).

let uncurry: <a, b, c>(_: (_: a) => (_: b) => c) => (_: [a, b]) => c

The call uncurry(f,[x,y]) has the same value as f(x)(y).

let fst: <a, b>(_: [a, b]) => a

Projecting the first component of a pair

let snd: <a, b>(_: [a, b]) => b

Projecting the second component of a pair.

let failwith: <err, a>(_: err) => a

The call failwith(e) terminates the execution with the value e, standing for an error. Note: Using a string for an error message can be costly in terms of size.

let bytes: <a>(_: a) => external_bytes<a>

The function `bytes` encodes an integer or a natural number to bytes using the big-endian encoding. For integers, negative numbers are considered in two's complement representation.

let assert_with_error: (_: bool) => (_: string) => unit

The call assert_with_error(cond, error) terminates the execution with the string error (that is, an error message) if, and only if, the boolean condition cond is false.

let assert: (_: bool) => unit

The call assert(cond) terminates the execution with the string "failed assertion" if, and only if, the boolean condition cond is false.

let assert_some_with_error: <a>(_: option<a>) => (_: string) => unit

The call assert_some_with_error(opt, err) terminates the execution with the string err (that is, an error message) if, and only if, opt is None().

let assert_some: <a>(_: option<a>) => unit

The call assert_some(opt) terminates the execution with the string "failed assert some" if, and only if, opt is None().

let assert_none_with_error: <a>(_: option<a>) => (_: string) => unit

The call assert_none_with_error(opt, err) terminates the execution with the string err (that is, an error message) if, and only if, opt is an optional value different from None().

let assert_none: <a>(_: option<a>) => unit

The call assert_none(opt) terminates the execution with the string "failed assert none" if, and only if, opt is not None().

let abs: (_: int) => nat

The call abs(i) is the absolute value of i.

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

The call is_nat(i) is Some(n), where n is the absolute value of i, if, and only if, i is positive or zero.

let int: <a>(_: a) => int

The call int(v) casts the value v to an integer.

For natural numbers, the function int is the identity cast from nat to int. For BLS12-381 field elements, the returned value is always between 0 (inclusive) and the order of the BLS12-381 field (exclusive). For bytes, the function int decodes the bytes using the big-endian encoding, where negative numbers are considered in two's complement representation.

let nat: (_: bytes) => nat

The call nat(b) casts the bytes b into a natural number.

let ediv: <a, b>(_: a) => (_: b) => external_ediv<a, b>

The call ediv(z1, z2), where z1 and z2 are either of type int or nat, returns None() if z2 is zero; otherwise, it returns the pair [q,r], where q is the quotient and r the positive remainder, as is the convention of the mathematical Euclidian division.

type dynamic_entrypoints = big_map<nat, bytes>

Dynamic entrypoints

Dynamic entrypoints are lazy entrypoints stored in the contract within a big_map. They can then be updated or removed without deploying a new contract.

A contract with dynamic entrypoints must have at least one @entry declaration (as any other contract); it also must obey some convention on storage type definition and have at least one @dyn_entry declaration.

LIGO will then include the defined dynamic entries into the contract initial storage.

type dynamic_entrypoint

A value of type `dynamic_entrypoint` denotes a typed key in an dynamic entrypoint

type michelson_program

type typed_address

type mutation

type michelson_contract

type pbt_gen

type int64

type views

type test_exec_error_balance_too_low = { contract_balance: mav; contract_too_low: address; spend_request: mav }

type test_exec_error = ["Balance_too_low", test_exec_error_balance_too_low] | ["Other", string] | ["Rejected", michelson_program, address]

type test_exec_result = ["Fail", test_exec_error] | ["Success", nat]

type test_baker_policy = ["By_account", address] | ["By_round", int] | ["Excluding", list<address>]

type pbt_test<a> = [pbt_gen<a>, (_: a) => bool]

type pbt_result<a> = ["Fail", a] | ["Success"]

type unforged_ticket<s> = { amount: nat; ticketer: address; value: s }

type module_contract<param, storage> = [(_: [param, storage]) => [list<operation>, storage], views<storage>, option<dynamic_entrypoints>]

type origination_result<param, storage> = { addr: typed_address<param, storage>; code: michelson_contract<param, storage>; size: int }

type implicit_address = typed_address<unit, unit>