Skip to main content
Version: 1.0.0


The following functions are available under the Tezos. namespace.

let Tezos.create_ticket: 'value => nat => option<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). The resulting value is None if the amount is zero.

const my_ticket1 = Option.unopt(Tezos.create_ticket(1, 10n));
const my_ticket2 = Option.unopt(Tezos.create_ticket("one", 10n));
let Tezos.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 tuple destructuring:

const v2 = do {
let [[_addr, [payload, _amt]], _ticket] = Tezos.read_ticket (my_ticket2);
return payload;
let Tezos.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 [ta, tb] =
match(Tezos.split_ticket(my_ticket1, [6n, 4n])) {
when(None()): failwith("amt_a + amt_v != amt");
when(Some(split_tickets)): split_tickets
let Tezos.join_tickets = <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 ta = Option.unopt(Tezos.create_ticket(1, 10n));
const tb = Option.unopt(Tezos.create_ticket(1, 5n));
const tc = Tezos.join_tickets([ta, tb]);