CIP-112 transaction parsing guidelines
CIP-112 introduces a dedicated DamlEventLog interface to record transaction events. This
interface exposes a nonconsuming choice which is exercised within a transaction to record
relevant events.
A ledger client can query events on this interface to obtain an ordered series of events from the
participant node. You can refer to the relevant pieces of the Canton Network documentation
for additional details.
The
EventLog interface is not implemented in Registry Daml models prior to the 0.14 release. These
guidelines unfortunately do not apply to these earlier versions.As long as you support Registry 0.13 and older, you will need to use the below CIP-56
transaction parsing guidelines.Example ledger query
Example ledger query
Here is an example query, using the JSON API endpoint for paginated updates
You will then need to filter the output events for exercises of the
v2/updates/get-updates-page.EventLog_HoldingsChange
choice and look at the content of the choiceArgument object.Transfer parsing example
Transfer parsing example
For a transfer from Note that both the
issuer to holder, the choiceArgument object of the ExercisedEvent
includes the relevant information:- instrument admin
- relevant account
- transfer leg (
SenderSideif the relevant account is the sender,ReceiverSideotherwise)
SenderSide and ReceiverSide are logged separately. The same format is used
for allocations (where there could be multiple TransferLegs for a given event).Mint parsing example
Mint parsing example
Mints only have a Likewise, burns only log a
ReceiverSide leg.SenderSide leg.A note on ledger pruning
In order to keep a Canton participant node healthy, it should be pruned at regular intervals. This means that the ledger will generally not retain all of the transaction history. The methodology described in this guide only applies to data that has not been pruned from the ledger. If the user needs to retain transaction data for a period of time longer than their pruning window, they should move the data outside of the Canton participant node before it gets pruned. For reference, the Registry operator node uses a retention period of 30 days for pruning.Other transaction parsing options
If you have been integrating with Registry prior to version 0.14, you are probably using one of the below options for transaction history parsing.CIP-56 transaction parsing guidelines
The first iteration of the Token Standard introduced a set of transaction history parsing guidelines. These are documented in the relevant pieces of the Canton Network documentation.Mint and Burn workflows
Mint and burn workflows are not part of the Token Standard and use Daml templates rather than interfaces. Choice exercises resulting in a successful mint or burn are tagged with the appropriate metadata as part of their choice result. For instance, the choice result for a successful burn includesTransaction parsing based on ExecutedTransfer, ExecutedMint, ExecutedBurn
Versions of Registry prior to 0.14 create an activeExecuted* contract upon a successful transfer, mint,
or burn. Similar contracts are created when a request is rejected by a counterparty.
These can be retrieved via an ACS query in order to reconstruct transaction history. They should
however be regularly archived by the corresponding
registrar in order to prevent excessive ACS
growth.
Batch archival can be performed in order to minimize the cost of this operation.
Disable the creation of Executed* contracts
Parties with theregistrar role can disable the creation of Executed* contracts on versions of
the app prior to 0.14.
This is controlled by a flag in the RegistrarService template, which can be set by calling
Template-based transaction parsing
A final transaction parsing option is to rely on concrete template choice exercises, such as exercises ofMigrating from Executed contracts
Up until version0.13 of the Registry App, an ExecutedTransfer contract is created by default
on each transfer transaction. Similar contracts are created for mint and burn operations.
While these contracts are very convenient to use, they are not sustainable as they lead to unbounded
ACS growth unless they get regularly archived by the instrument admin.
Thus, starting with version 0.14, these โexecutionโ contracts are no longer created.
Tokenizers that rely on these contracts to determine whether a transfer, mint, or burn has occurred
must switch to transaction history parsing based on ledger events before adopting the 0.14
release.
The following sub-section outlines a migration path, which
- relies on Executed contracts for transactions using the
0.13DARS or older - uses CIP-112 transaction parsing for transactions using the
0.14DARS or newer
1
Determine a storage solution for transaction history
It is not the role of the Canton participant node to store your entire transaction history,
especially if your data retention requirements span a period of months or years.You should determine a durable store for the history that you need to retain, such as a
Postgres DB. See the note on ledger pruning for why this data should be
stored outside the Canton participant node.
2
Populate storage from Executed* contracts
Query the active
ExecutedMint, ExecutedBurn, and ExecutedTransfer contracts for the
parties and instruments whose history you need to retain.Copy the relevant contract payloads and transaction identifiers (updateId, recordTime) into
the durable store.This needs to be an ongoing process, as transactions using Registry versions 0.12 and 0.13 keep
creating these contracts.Archive the ingested Executed* contracts to reduce the burden on the participant node. This
step is optional, but recommended.
Archival of these contracts can be done in a batched fashion in order to minimize transaction
cost.3
Introduce ledger events-based transaction parsing based on exercises of the EventLog_HoldingsChange interface
Introduce an additional process that updates the stored transaction history based on the parsing
guidelines introduced with CIP-112.
4
Install the 0.14 DARS
You can now install the
0.14 DARS. Transactions using these models will be caught only by the
ingestion process introduced in step 3.5
Unvet Registry DARS prior to 0.14
Once you (or the Registry operator) no longer support versions of the Registry App prior to
0.14, you can safely unvet the corresponding DARS, so that these can no longer be used for
transactions involving your assets.6
Disable ingestion of Executed contracts
Finally, you can switch off the ingestion process introduced in Step 2. Transaction parsing is
now fully driven by CIP-112 event-based parsing.