--- id: toplevel title: Top-Level description: Available functions at the top level hide_table_of_contents: true --- import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; These types and functions are available without any needed prefix. type address type address type address An untyped address which can refer to a smart contract or account. type big_map ('key, 'value) type ('key, 'value) big_map 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)`. ```pascaligo group=big_map type move is int * int type register is big_map (address, move) ``` The type of a big map from values of type `key` to values of type `value` is `(key, value) big_map`. ```cameligo group=big_map type move = int * int type register = (address, move) big_map ``` The type of a big map from values of type `key` to values of type `value` is `big_map(key, value)`. ```reasonligo group=big_map type move = (int, int); type register = big_map(address, move); ``` Be aware that a `big_map` cannot appear inside another `big_map`. type bool type bool type bool type bytes type bytes type bytes type contract('parameter) type 'parameter contract type contract('parameter) A typed contract. Use `unit` as `parameter` to indicate an implicit account. type chain_id type chain_id type chain_id The identifier of a chain, used to indicate test or main chains. type int type int type int An integer. The only size limit to integers is gas. type key type key type key A public cryptographic key. type key_hash type key_hash type key_hash The hash of a public cryptographic key. type list ('t) type 't list type list('t) A sequence of elements of the same type. type map ('key, 'value) type ('key, 'value) map type map ('key, 'value) The type of a map from values of type `key` to values of type `value` is `map (key, value)`. ```pascaligo group=maps type move is int * int type register is map (address, move) ``` The type of a map from values of type `key` to values of type `value` is `(key, value) map`. ```cameligo group=maps type move = int * int type register = (address, move) map ``` The type of a map from values of type `key` to values of type `value` is `map (key, value)`. ```reasonligo group=maps type move = (int, int); type register = map (address, move); ``` type nat type nat type nat A natural number. The only size limit to natural numbers is gas. type operation type operation type operation An operation emitted by the contract type set ('value) type 'value set type set('value) type signature type signature type signature A cryptographic signature. type string type string type string A sequence of characters. type tez type tez type tez A specific type for tokens. type timestamp type timestamp type timestamp A date in the real world. type unit type unit type unit function is_nat: int -> option(nat) val is_nat: int -> nat option let 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 val abs: int -> nat let abs: int => nat Cast an `int` to `nat`. function int: nat -> int val int: nat -> int let int: nat => int Cast an `nat` to `int`. const unit: unit val unit: unit let (): unit A helper to create a unit. function failwith : 'a -> unit val failwith : 'a -> unit let 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. ```pascaligo 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) ``` ```cameligo let main (p,s : int * unit) = if p > 10 then failwith "Failure." ``` ```reasonligo let main = ((p,s) : (int, unit)) => if (p > 10) { failwith ("Failure."); }; ``` `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. function assert : bool -> unit val assert : bool -> unit let 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) val ediv : int -> int -> (int * nat) option val ediv : mutez -> nat -> (mutez * mutez) option val ediv : mutez -> mutez -> (nat * mutez) option val ediv : nat -> nat -> (nat * nat) option let ediv: (int, int) => option((int, nat)) let ediv: (mutez, nat) => option((mutez, mutez)) let ediv: (mutez, mutez) => option((nat, mutez)) let 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)`.