Version: Next


const balance : tez

Get the balance for the contract.

function main (const p : unit; const s: tez) : list (operation) * tez is
((nil : list (operation)), Tezos.balance)

Note that balance and Current.balance are deprecated.

const now : timestamp

Returns the current time as a unix timestamp.

In LIGO, timestamps are type compatible in operations with integers. This lets you set for instance time constraints for your smart contracts like this:


24 hours from now#

const today: timestamp =;
const one_day: int = 86_400;
const in_24_hrs: timestamp = today + one_day;
const some_date: timestamp = ("2000-01-01T10:10:10Z" : timestamp);
const one_day_later: timestamp = some_date + one_day;

Note that now is deprecated. Please use

24 hours ago#

const today: timestamp =;
const one_day: int = 86_400;
const in_24_hrs: timestamp = today - one_day;

Note that now is deprecated. Please use

Comparing Timestamps#

You can also compare timestamps using the same comparison operators as for numbers

const not_tommorow: bool = ( = in_24_hrs)

Note that now is deprecated. Please use

const amount : tez

Get the amount of tez provided by the sender to complete this transaction.

function threshold (const p : unit) : int is
if Tezos.amount = 100tz then 42 else 0

Note that amount is deprecated.

const sender : address

Get the address that initiated the current transaction.

function main (const p : unit) : address is Tezos.sender

Note that sender is deprecated. Please use Tezos.sender.

function address : contract 'a -> address

Get the address associated with a value of type contract.

function main (const p : key_hash) : address is block {
const c : contract (unit) = Tezos.implicit_account (p)
} with Tezos.address(c)

Note that implicit_account and address are deprecated. Please use Tezos.implicit_account and Tezos.address instead.

const self_address : address

Get the address of the currently running contract.

function main (const p : unit) : address is Tezos.self_address

Note that self_address is deprecated. Please use Tezos.self_address.

function self : string -> contract 'a

Typecast the currently running contract with an entrypoint annotation. If your are using entrypoints: use "%bar" for constructor Bar If you are not using entrypoints: use "%default"

function main (const p : unit) : contract(unit) is block {
const c : contract(unit) = Tezos.self("%default") ;
} with c
function implicit_account : key_hash -> contract 'a

Get the default contract associated with an on-chain key-pair. This contract does not execute code, instead it exists to receive tokens on behalf of a key's owner.

See also:

function main (const kh: key_hash) : contract (unit) is
Tezos.implicit_account (kh)

Note that implicit_account is deprecated. Please use Tezos.implicit_account.

const source : address

Get the originator (address) of the current transaction. That is, if a chain of transactions led to the current execution get the address that began the chain. Not to be confused with Tezos.sender, which gives the address of the contract or user which directly caused the current transaction.

⚠️ There are a few caveats you should keep in mind before using Tezos.source over Tezos.sender:

  1. Tezos.source will never be a contract, so if you want to allow contracts (multisigs etc) to operate your contract, you need to use Tezos.sender
  2. -- in general it is somewhat unsafe to assume that Tezos.source understands everything that is going to happen in a transaction. If Tezos.source transfers to a malicious (or sufficiently attackable) contract, that contract might potentially transfer to yours, without Tezos.source's consent. So if you are using Tezos.source for authentication, you risk being confused. A good historical example of this is bakers paying out delegation rewards. Naive bakers did (and probably still do) just use tezos-client to transfer to whatever KT1 delegates they had, even if those KT1 were malicious scripts.
function main (const p: unit) : address is Tezos.source

Note that source is deprecated. Please use Tezos.source.

function failwith : 'a -> unit

See failwith

const chain_id : chain_id

Get the identifier of the chain to distinguish between main and test chains.

This is mainly intended to avoid replay attacks between the chains, and can currently only be used together with Bytes.pack and Bytes.unpack.

type storage is bytes
function main (const ignore : unit; const storage: storage) :
(list(operation) * storage) is block {
const packed : bytes = Bytes.pack (Tezos.chain_id);
if (storage =/= packed) then {
failwith("wrong chain")
} else
} with ((nil: list(operation)), packed)
function transaction : 'parameter -> mutez -> contract('parameter) -> operation

Transfer tez to an account, or run code of another smart contract.

To indicate an account, use unit as parameter.

Note that `transaction` is deprecated. Please use `Tezos.transaction` instead.
function set_delegate : option(key_hash) -> operation

Modify the delegate of the current contract.

The operation fails when:

  • the delegate is the same as current delegate
  • the keyhash is not of a registered delegate

Use None to withdraw the current delegate.

Note that `set_delegate` is deprecated. Please use `Tezos.set_delegate` instead.
function get_contract_opt : address -> option(contract('parameter))

Get a contract from an address.

When no contract is found or the contract doesn't match the type, None is returned.

Note that `get_contract` and `get_contract_opt` are deprecated. Please use `Tezos.get_contract_opt` instead.
function get_entrypoint_opt : string -> address -> option(contract('parameter))

Get a contract from an address and entrypoint.

Entrypoints are written in the form of: %entrypoint.

When no contract is found or the contract doesn't match the type, None is returned.

Note that `get_entrypoint` and `get_entrypoint_opt` are deprecated. Please use `Tezos.get_entrypoint_opt` instead.
const level : nat

Get the current block level.

function pairing_check : list(bls12_381_g1 * bls12_381_g2) -> bool

Verify that the product of pairings of the given list of points is equal to 1 in Fq12. Returns true if the list is empty. Can be used to verify if two pairings P1 and P2 are equal by verifying P1 * P2^(-1) = 1. (extracted from Tezos documentation)

function never : never -> 'a

Eliminate a value of the type never using the instruction NEVER from Michelson.


Delphi protocol introduced the following sapling types (state and transaction) with N being an int singleton

type st is sapling_state (8)
type tr is sapling_transaction (8)
const sapling_empty_state : sapling_state (N)
const x : st = Tezos.sapling_empty_state ;

Sapling empty state

function sapling_verify_update : sapling_transaction (N) -> sapling_state (N) -> option (int * sapling_state (N))

Verify sapling update

function f (const tr : tr) : (int * st) is
case (Tezos.sapling_verify_update (tr, x)) of
| Some (x) -> x
| None -> (failwith ("failed") : (int * st))


function create_ticket : 'value -> nat -> ticket ('value)

To create a ticket, the value and the amount of tickets to be created needs to be provided. The ticket will also contain the contract address it originated from (which corresponds to Tezos.self).

const my_ticket1 : ticket (int) = Tezos.create_ticket (1, 10n)
const my_ticket2 : ticket (string) = Tezos.create_ticket ("one", 10n)
function read_ticket : ticket ('value) -> (address * ('value * nat)) * ticket ('value)

Reading a ticket will return a tuple with the ticket address, the value and the same ticket for later use. A ticket is only consumed when it is dropped (e.g. DROP-ed from the michelson stack) so if the returned ticket isn't stored in some form by your contract, it will be fully consumed.

To read the content of a ticket, you need to use pattern matching

const v : int =
case (Tezos.read_ticket (my_ticket1)) of
| (content,ticket) -> (
case content of
| (addr,x) -> (
case x of
| (payload,amt) -> (
) end
) end
) end
function split_ticket : ticket ('value) -> nat * nat -> option (ticket('value) * ticket ('value))

To partially use/consume a ticket, you have to split it. Provided a ticket and two amounts, two new tickets will be returned to you if, and only if, the sum equals to the amount of the original ticket.

const x =
case Tezos.split_ticket (my_ticket1, (6n, 4n)) of
| None -> (failwith ("amt_a + amt_v != amt") : (ticket(int) * ticket(int)))
| Some (split_tickets) -> split_tickets
function join_ticket : ticket('value) * ticket ('value) -> option (ticket ('value))

To add two tickets, you have to join them. This works as the inverse of Tezos.split_ticket. Provided two tickets with the same ticketer and content, they are deleted and a new ticket will be returned with an amount equal to the sum of the amounts of the input tickets.

const tc =
block {
const ta = Tezos.create_ticket(1, 10n);
const tb = Tezos.create_ticket(1, 5n)
} with Tezos.join_tickets((ta, tb))


If a contract storage type contains a ticket, you must destructure the parameter-storage pair within the body to preserve storage linearity (e.g. avoid DUP-ing storage). For the same reasons, if tickets are stored in a map/big_map you must use the new operator get_and_update to update your bindings.

type storage is big_map (string, ticket(int))
type parameter is int
type return is list (operation) * storage
function main (const i : parameter ; const store : storage) : return is
block {
const my_ticket1 : ticket(int) = Tezos.create_ticket (i, 10n) ;
const res = Big_map.get_and_update("hello", (Some (my_ticket1)), store) ;
var res : return := ((nil : list (operation)), store) ;
case res of
| (t,x) -> res := ((nil : list (operation)), x)
} with res