Skip to main content
Version: 1.7.0

tezos

Tezos-specific functions

module next

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

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

let self: <a>(_: 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.

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

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

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

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

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

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

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

The call Tezos.get_entrypoint_opt(entrypoint, addr) has the same behaviour as Tezos.get_contract_opt(addr), with the additional constraint that the contract must have an entrypoint named entrypoint. In other words, Tezos.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 Tezos.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 create_contract: <param, storage>(_: entrypoint<param, storage>) => (_: option<key_hash>) => (_: tez) => (_: storage) => [ operation, address ]

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Operation.create_contract` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.create_contract(e,d,a,s) returns a contract creation operation (origination) for the entrypoint e (as a function) with optional delegate d, initial amount a and initial storage s, together with the address of the created contract. Note that the created contract cannot be called immediately afterwards (that is, Tezos.get_contract_opt on that address would return None()), as the origination must be performed successfully first, for example by calling a proxy contract or itself.

let set_delegate: (_: option<key_hash>) => operation

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Operation.set_delegate` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.set_delegate(d) evaluates in an operation that sets the delegate of the current smart contract to be d, where d is an optional key hash. If None(), the delegation is withdrawn. If the contract has no delegation, then no change occurs. If d is Some(kh), where kh is the key hash of a registered delegate that is not the current delegate of the contract, then this operation sets the delegate of the contract to this registered delegate. A failure occurs if kh is the current delegate of the contract or if kh is not a registered delegate. However, the instruction in itself does not fail; it produces an operation that will fail when applied.

let transaction: <param>(_: param) => (_: tez) => (_: contract<param>) => operation

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Operation.transaction` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.transaction(param, amount, contract_addr) evaluates in an operation that will send the amount amount in mutez to the contract at the valid address contract_addr, with parameter param. If the contract is an implicit account, the parameter must be unit.

let call_view: <param, return>(_: string) => (_: param) => (_: address) => option<return>

The call Tezos.call_view(v, p, a) calls the view v with parameter param at the contract whose address is a. The value returned is None() if the view does not exist, or has a different type of parameter, or if the contract does not exist at that address. Otherwise, it is Some(v), where v is the return value of the view. Note: the storage of the view is the same as when the execution of the contract calling the view started.

let create_ticket: <a>(_: a) => (_: nat) => option<ticket<a>>

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.create` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.create_ticket(v, a) creates a ticket with value v and amount a. If the creation is a success, the value Some(t) is returned, where t is the ticket; otherwise, None() is the result. Note: Tickets cannot be duplicated.

let split_ticket: <a>(_: ticket<a>) => (_: [nat, nat]) => option<[ticket<a>, ticket<a>]>

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.split` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.split_ticket(t, [a1, a2]) results in a pair of tickets t1 and t2 such that the former owns the amount a1 and the later a2. More precisely, the value of the call is Some([t1, t2]) because signifying to the callee the failure of the splitting is achieved by returning the value None().

let join_tickets: <a>(_: [ticket<a>, ticket<a>]) => option<ticket<a>>

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.join` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.join_tickets(t1, t2) joins the tickets t1 and t2, which must have the same type of value.

let read_ticket: <a>(_: ticket<a>) => [[address, [a, nat]], ticket<a>]

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Ticket.read` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.read_ticket(t) returns t itself and the contents of t which is a pair [address, [value, amount]], where address is the address of the smart contract that created it.

let sapling_empty_state: <sap_t>sapling_state<sap_t>

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Sapling.empty_state` from `Tezos.Next` is encouraged for a smoother migration.

The evaluation of the constant Tezos.sapling_empty_state is an empty sapling state, that is, no one can spend tokens from it.

let sapling_verify_update: <sap_a>(_: sapling_transaction<sap_a>) => (_: sapling_state<sap_a>) => option<[bytes, [int, sapling_state<sap_a>]]>

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Sapling.verify_update` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.sapling_verify_update(trans, state), where the transaction trans can be applied to the state state, returns Some ([data, [delta, new_state]]), where data is the bound data (as bytes), delta is the difference between the outputs and the inputs of the transaction, and new_state is the updated state.

let emit: <event_type>(_: string) => (_: event_type) => operation

**Deprecated:** In a future version, `Tezos` will be replaced by `Tezos.Next`, and using `Operation.emit` from `Tezos.Next` is encouraged for a smoother migration.

The call Tezos.emit(event_tag, event_type) evaluates in an operation that will write an event into the transaction receipt after the successful execution of this contract. The event is annotated by the string event_tag if it is not empty. The argument event_type is used only to specify the type of data attachment.

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

let get_amount: (_: unit) => tez

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

let 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".

let get_min_block_time: (_: unit) => nat

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

let get_level: (_: unit) => nat

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

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

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

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

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

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

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