Skip to main content
Version: Next

ticket

create: <a>(value: a, amount: nat) => option<ticket<a>>

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

split: <a>(_: ticket<a>, amounts: [nat, nat]) => option<[ticket<a>, ticket<a>]>

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

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

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

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

The call read(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.