Tezos has so-called tickets, which are authenticated quantities issued by contracts. A ticket of type
sp.ticket[t] has three elements:
A source, indicating the contract that issued the ticket.
A value of type
A quantity of type
- sp.ticket(content: t, quantity: sp.nat) → sp.ticket[t]
Create a ticket with the given content and quantity. The ticket source is the address of
- sp.read_ticket(ticket: sp.ticket[t]) → sp.pair[sp.tuple[sp.address, t, sp.nat], sp.ticket[t]]
Reads the contents of a ticket. Returns a pair of:
The ticket data, itself a triple of the ticket's source, value, and quantity.
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_ticketcannot be used again. Instead the returned copy can still be used.
- sp.join_tickets(sp.pair[sp.ticket[t], sp.ticket[t]]) → sp.option[sp.ticket[t]]
Makes two tickets into one by adding up their quantities. Returns
Noneif the tickets differ in their source or value.
- sp.split_ticket(ticket: sp.ticket[t], amounts: sp.pair[sp.nat, sp.nat]) → sp.option[sp.pair[sp.ticket[t], sp.ticket[t]]]
Splits a ticket into two parts.
sp.split_ticket(ticket, (amount1, amount2))returns two tickets with the specified amounts.
Noneis returned if
amount1 + amount2is not equal to