Skip to main content
Version: Next

next

module operation

module view

module ticket

module sapling

let get_sender: (_: unit) => address

The call get_sender() is the address of the contract (that is, a smart contract or an implicit account) that initiated the current internal transaction. Note that, if transactions have been chained, that address could be different from get_source().

let get_source: (_: unit) => address

The call get_source() is the address of the implicit account that initiated the current transaction. If transactions have been chained, that address is different from get_sender().

let self: <a>(_: string) => contract<a>

The call self(entrypoint) is the address of the current smart contract, that is, the smart contract containing the call. For the address of the smart contract actually executing the call, because it is embedded in a lambda sent to another smart contract, use get_self_address instead. The string entrypoint is the name of a valid entrypoint such that entrypoint is not "default", or the empty string denoting the "default" entrypoint (which is the root of the smart contract parameter if no "default" entrypoint is explicitly defined). If the contract does not have the specified entrypoint, the call results in an type checking error.

let get_self_address: (_: unit) => address

The call get_self_address() is the address of the smart contract actually executing the call, as a value of type address. That contract can be different from the one containing the call if the call is in a lambda transmitted to another smart contract. Therefore, it is assumed that, in general, the type of the executing contract is statically unknown, so the return type of get_self_address is not 'a contract, but address. (See self.)

let address: <a>(_: contract<a>) => address

The call address(contract) casts the address of the smart contract contract into the more general value of type address.

let implicit_account: (_: key_hash) => contract<unit>

The call implicit_account(kh) casts the public key hash kh into the address of its implicit account. Note that addresses of implicit accounts always have the type contract<unit>.

let get_contract_opt: <param>(_: address) => option<contract<param>>

The call get_contract_opt(addr) casts the address addr into that of a contract address, if such contract exists. The value of the call is None() if no such contract exists, otherwise Some contract, where contract is the contract's address. Note: The address of an implicit account has type unit contract.

let get_contract_with_error: <param>(_: address) => (_: string) => contract<param>

The call get_contract_with_error(addr, error) casts the address addr into that of a contract address, if such contract exists. If not, the execution fails with the error message error.

let get_contract: <param>(_: address) => contract<param>

The call get_contract(addr) casts the address addr into that of a smart contract address, if such contract exists. The call fails with the message "bad address for get_contract" if no such smart contract exists. Note: The address of an implicit account has type contract<unit>.

let get_entrypoint_opt: <param>(_: string) => (_: address) => option<contract<param>>

The call get_entrypoint_opt(entrypoint, addr) has the same behaviour as get_contract_opt(addr), with the additional constraint that the contract must have an entrypoint named entrypoint. In other words, get_entrypoint_opt(entrypoint, addr) casts the address addr into that of a smart contract address, if such contract exists and has an entrypoint named entrypoint. The value of the call is None() if no such smart contract exists, otherwise Some(contract), where contract is the smart contract's address. Note: The address of an implicit account has type contract<unit>.

let get_entrypoint: <param>(_: string) => (_: address) => contract<param>

The call get_entrypoint(entrypoint, addr) casts the address addr into that of a smart contract address, if such contract exists and has an entrypoint named entrypoint. If no such smart contract exists, the execution fails with the error message "bad address for get_entrypoint". Note: The address of an implicit account has type contract<unit>.

let open_chest: (_: chest_key) => (_: chest) => (_: nat) => option<bytes>

The function [open_chest] opens a timelocked chest given its key and the time. The result is a byte option depending if the opening is correct or not.

let get_balance: (_: unit) => tez

The call get_balance() returns the balance in mutez of the account associated to the currently executed smart contract, including any mutez added by the calling transaction.

let get_amount: (_: unit) => tez

The call get_amount() returns the amount in mutez of the current transaction.

let get_now: (_: unit) => timestamp

The call get_now() returns the minimal injection time for the current block, namely the block whose application triggered this execution. The minimal injection time constitutes an estimate of the moment when the current block is injected, hence the name "now".

let get_min_block_time: (_: unit) => nat

The call get_min_block_time() returns the minimal delay between two consecutive blocks in the chain.

let get_level: (_: unit) => nat

The call get_level() returns the current block level.

let get_chain_id: (_: unit) => chain_id

The call get_chain_id () returns the identifier of the chain on which the smart contract is executed.

let get_total_voting_power: (_: unit) => nat

The call get_total_voting_power() returns the total voting power of all contracts. The total voting power coincides with the sum of the stake of every contract in the voting listings. The voting listings is calculated at the beginning of every voting period.

let voting_power: (_: key_hash) => nat

The call voting_power(contract_kh) returns the voting power of a given contract specified by the key hash contract_kh. This voting power coincides with the weight of the contract in the voting listings (that is, the stake) which is calculated at the beginning of every voting period.

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

The call never(n) is never meant to be executed, as the type never is inhabited, but to instruct the typechecker that a branch in the control flow, for example, in a pattern matching, is dead.

let pairing_check: (_: list<[bls12_381_g1, bls12_381_g2]>) => bool

The call pairing_check(pairings) verifies that the product of pairings of the given list of points pairings is equal to 1 in the field Fq12. It evaluates in true if the list is empty. This function can be used to verify if two pairings P1 and P2 are equal by verifying P1 * P2^(-1) = 1.

let constant: <a>(_: string) => a