Skip to content
On this page

Tickets

Tezos has so-called tickets, which are authenticated quantities issued by contracts. A ticket of type sp.ticket[t] has three elements:

  • Its ticketer, indicating the contract that issued the ticket.

  • Its contents of type t.

  • Its amount of type sp.nat.

sp.ticket(contents: t, amount: sp.nat) → sp.ticket[t]

Create a ticket with the given contents and amount. The ticketer is the address of sp.self_address.

sp.read_ticket(ticket: sp.ticket[t]) → sp.pair[sp.record(ticketer=sp.address, contents=t, amount=sp.nat), sp.ticket[t]]

Reads the contents of a ticket. Returns a pair of:

  • The ticket data, itself a record of the ticket's ticketer, contents, and amount.

  • A copy of the original ticket that can still be used.

Note that mentioning a ticket consumes it, i.e. the argument to sp.read_ticket cannot be used again. Instead the returned copy can still be used.

sp.join_tickets(t1: sp.ticket[t], t2: sp.ticket[t]) → sp.ticket[t]

Makes two tickets into one by adding up their quantities. Fails if the tickets differ in their ticketer or contents.

sp.split_ticket(ticket: sp.ticket[t], amount1: sp.nat, amount2: sp.nat) → sp.pair[sp.ticket[t], sp.ticket[t]]

Splits a ticket into two parts with the specified amounts. Fails if amount1 + amount2 is not equal to ticket's amount.