Skip to main content
Version: Next

tezos

Tezos-specific functions

module Operation

module View

module Ticket

module Sapling

get_sender: (_: unit) => address

The call Tezos.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 Tezos.get_source().

get_source: (_: unit) => address

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

self: <a>(entrypoint: string) => contract<a>

The call Tezos.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 Tezos.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.

get_self_address: (_: unit) => address

The call Tezos.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 Tezos.get_self_address is not 'a contract, but address. (See Tezos.self.)

address: <a>(contract_addr: contract<a>) => address

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

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

The call Tezos.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>.

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" as "None"] if no such contract exists, otherwise ["Some" as "Some", contract], where contract is the contract's address. Note: The address of an implicit account has type contract<unit>.

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

The call Tezos.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.

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

The call Tezos.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>.

get_entrypoint_opt: <param>(entrypoint: string, addr: 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" as "None"] if no such smart contract exists, otherwise ["Some" as "Some", contract], where contract is the smart contract's address. Note: The address of an implicit account has type contract<unit>.

get_entrypoint: <param>(entrypoint: string, addr: 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>.

open_chest: (key: chest_key, _: chest, time: 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.

get_balance: (_: unit) => tez

The call Tezos.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.

get_amount: (_: unit) => tez

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

get_now: (_: unit) => timestamp

The call Tezos.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".

get_min_block_time: (_: unit) => nat

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

get_level: (_: unit) => nat

The call Tezos.get_level() returns the current block level.

get_chain_id: (_: unit) => chain_id

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

get_total_voting_power: (_: unit) => nat

The call Tezos.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.

voting_power: (_: key_hash) => nat

The call Tezos.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.

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

The call Tezos.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.

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

The call Tezos.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.

constant: <a>(hash: string) => a

The call to Tezos.constant(hash) returns the value stored on-chain whose hash value is hash (global constants). This call can fail when the contract is originated if the hash is invalid or the expansion of the global constant is ill-typed, or too large (gas consumption).