Compact Transaction Identifier
A Compact Transaction Identifier (CTID) is a unique identifier for a validated transaction that applies across any network, not just the XRP Ledger Mainnet.
The differences between a CTID and a transaction's identifying hash are as follows:
- A CTID identifies a validated transaction based on its network ID, ledger index, and position within the ledger. Since it specifies which network a transaction has been validated on, it can be used in contexts where you are interacting with more than one network, such as connecting to sidechains. A CTID is 64 bits, typically written as 16 characters of uppercase hexadecimal starting with
C, for example
- An transaction's identifying hash identifies a signed transaction based on its contents, regardless of if that transaction has been validated on any chains. Since it's a cryptographic hash, it can also be used to prove that the transaction contents are intact. A transaction hash is 256 bits, typically written as 64 characters of hexadecimal, for example
Caution: Do not try to use a CTID for a transaction that has not yet been validated. The canonical order of the transaction can change between when the transaction is initially applied and when it is validated by the consensus process, resulting in a CTID that identifies a different transaction or no transaction at all.
A CTID contains the following parts, in order (big-endian):
- 4 bits: The hex nibble
Cindicating that this is a CTID.
- 28 bits: The ledger index of the ledger where the transaction was validated.
- 16 bits: The transaction index, its place within the ledger's canonical order. This is provided as the field
TransactionIndexin transaction metadata.
- 16 bits: The network ID of the network that validated this transaction.
Note: The ledger index is normally stored as a 32-bit unsigned integer which increases by 1 each time a new ledger is created. If a network's ledger index is greater than 268,435,455, it won't fit in 28 bits, so the leading
C should be incremented to
F as necessary. This is not expected to be necessary until at least the year 2043.
For more information including sample code and background, see the XLS-37d Standard .