Skip to content
/ CTID Public

Improved Concise Transaction Identifier (CTIM) code samples and test cases

Notifications You must be signed in to change notification settings

XRPLF/CTID

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quickstart

Improved Concise Transaction Identifier (CTID)

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

Function prototypes (pseudocode)

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 };

Mainnet example

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'

Hooks testnet v3 example

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'

About

Improved Concise Transaction Identifier (CTIM) code samples and test cases

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published