https://gitlab.com/tezos/tezos/-/milestones/118
The goal of this project is to provide more transparency for indexers with regards to ticket ownership. More specifically, we propose to:
(1) makes it easier for indexers to scan blocks and traverse the transaction receipts in order to update their ticket balance tables. (2) can be used on originated contracts to retrieve the current ticket balance for an originated contract. (3) can be used for checking balances for a specific ticket type and contracts, and also works for implicit accounts and rollup addresses.
Once we have (1) and (2) it would be possible for indexers to reconstruct a "global ticket table" that keeps track of all ticket ownership (Note: let us know if this is not the case). This can be done by:
(3) is meant to only be used as a double-check/validate ticket ownership.
The idea is to make changes to ticket ownership part of the transaction (and internal origination) receipts, similar to balance updates. Ticket updates consist of a list of ticket-tokens and account updates.
A ticket-token is the combination of a ticketer (the creator of the ticket) and ticket content (a value of some comparable Michelson type).
For each ticket-token, we provide a list of account and balance update pairs, which we call ticket balance updates, as in:
Ticket balance updates represent increase/decrease of tickets in the storage. They are included in receipts whenever:
Suppose that:
tz_a
calls KT_A
.KT_A
mints a ticket and stores it in it's storage.A single ticket should be added to KT_A
's storage, which is reflected in the receipt as:
Suppose:
tz_a
calls KT_A
.KT_A
reads one ticket from storage and sends it to KT_B
.KT_B
stores the received ticket.One ticket is removed from KT_A
's storage by the initial transaction and one ticket is added to KT_B
's storage by the internal transaction:
Suppose:
tz_a
calls KT_A
.KT_A
mints a ticket and sends it to KT_B
.KT_B
stores the ticket it received.This transaction will not change the tickets in storage of KT_A
and will increase the ticket in storage KT_B
by one:
Suppose:
tz_a
calls KT_A
with one ticket in the parameter
KT_A
stores the received ticket.A ticket is removed from tz_a
and added to the storage of KT_A
via subsequent internal operation:
Suppose:
tz_a
sends one ticket to KT_A
KT_A
reads one additional ticket from storage and sends one ticket each to KT_B
and KT_C
.KT_B
stores the ticket.KT_C
does not store the ticket (i.e. throws it away)The resulting receipt will look like:
Note that you can get the net-ticket balance update of the a ticket for any transaction by adding up the corresponding Ticket updates
in the receipts:
For reference, here is what the full receipt would look like in JSON:
No receipt is provided for the following scenarios:
We will support receipts for all combinations of transactions between:
An alternative way of displaying the ticket updates is to have a single net-balance update at the top level of the receipt. For the "Example 5" it would look like:
All tickets owned by originated contracts exist in the respective contract’s storage. We can provide an RPC that scans the contract storage for tickets and returns a list of ticket balances.
The API will look like this:
For example:
Would return a breakdown of the tickets owned by KT1WuPpnvefGFqKMDHWHEXz7FpnTc5JfYCB7
like this:
Implicit accounts and rollup addresses may hold tickets but the tickets are not contained in any storage why it is not possible to retrieve them by using the RPC above.
Ticket ownership is tracked by the protocol as a table that maps a triple of owner x ticketer x content
to balance. However, the keys are hashed so it’s also not possible to iterate over the table and collect all ticket for a given contract. Instead what we can do is to provide an RPC that returns the balance of specific combination of owner x ticketer x content
, by looking up the balance from the ticket balance table in the context.
This RPC would need to receive four things:
The API will be aPOST
endpoint which can be called like:
With a request body that looks like:
And would return a single number representing the amount of ticket-tokens with the given ticketer and content held by the contract: