CTIDs are composed of 16 hex nibbles, and begin with a C
.
CXXXXXXXYYYYZZZZ
The identifier is divided into three fields.
Char Offset | Field | Size (bits) | Explanation |
---|---|---|---|
0 | C | 4 | Lead-in (ignore) |
1-7 | XXXXXXX | 28 | Ledger Sequence |
8-11 | YYYY | 16 | Transaction index (offset) within that ledger |
12-16 | ZZZZ | 16 | Network ID. |
Reference implementations are available for several languages. Click below to dive in.
Language | Implementation |
---|---|
Javascript | ctid.js |
Typescript | ctid.ts |
C++ | ctid.cpp |
Python 3 | ctid.py |
PHP 5 | ctid.php |
In this repo there are several reference implementations available for various languages but they all use the same function model.
function encodeCTID (
ledger_seq : number,
txn_index : number,
network_id : number) -> string;
function decodeCTID (ctid : string or number) -> {
ledger_seq : number,
txn_index : number,
network_id : number };
This transaction encodes in the following way:
encodeCTID(
77727448, // ledger sequence number the txn appeared in
54, // `TransactionIndex` as per metadata
0) // Network ID of mainnet is 0
'C4A206D800360000'
This transaction encodes in the following way:
encodeCTID(
428986, // ledger sequence number the txn appeared in
0, // `TransactionIndex` as per metadata
21338) // Network ID of hooks v3 is 21338
'C0068BBA0000535A'