0037 XLS-37d - Improved Concise Transaction Identifier (CTID)
This standard provides a way to locate a validated transaction on any XRP Ledger Protocol Chain using its ledger sequence number, transaction index, and network ID rather than its transaction hash.
This identifier is only applicable for validated transactions. Non-validated or unsubmitted transactions cannot be identified using a CTID.
In an existing project (with package.json), install xls-37d with:
npm install xls-37d
or with yarn:
yarn add xls-37d
Reference documentation available here. Please note, this is still a work-in-progress.
An example encoding routine in typescript follows:
import xls37d from 'xls-37d';
const { ctid } = new xls37d.encode({
networkId,
lgrIndex,
txnIndex,
});
An example decoding routine in typescript follows:
import xls37d from 'xls-37d';
const { networkId, lgrIndex, txnIndex } = new xls37d.decode(ctid);
The XRP Ledger historically identifies ledgers and transactions (and other objects) using a namespace-biased 'SHA-512Half' hashing function, which results in a 64 hex nibble unique identifier.[1]
Since these hashes are derived from the contents of the data, each identifier is completely independent of consensus.
Example Transaction Hash (ID):
C4E284010276F8457C4BF96D0C534B7383087680C159F9B8C18D5EE876F7EFE7
Ledgers and transactions can be identified by their sequenced position.
As new ledgers are validated on XRP Ledger Protocol Chains, they are assigned a sequence number, which is always the previous ledger sequence plus one. The first ledger sequence is the genesis ledger with a value of one.
Ledgers can therefore be uniquely identified by a ledger_index
(sequence) [2] [3]. The only limitation is that the ledger needs to be closed before a sequence number can be used for identification.
The XRP Ledger is poised to become (or depending on the time of reading: has already become) an ecosystem of cooperatively interconnected XRPL Protocol Chains. It is imperative that users of these chains can efficiently locate a specific transaction on a specific chain. Therefore a network-aware transaction identifier is necessary.
[1] https://xrpl.org/basic-data-types.html#hashes
[2] https://xrpl.org/basic-data-types.html#ledger-index
[3] https://xrpl.org/ledger-header.html
[4] https://xrpl.org/consensus.html