Skip to content

Commit 34518e1

Browse files
committed
add quickstart
1 parent f633195 commit 34518e1

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Quickstart
2+
## Improved Concise Transaction Identifier (CTID)
3+
4+
CTIDs are composed of 16 hex nibbles, and begin with a `C`.
5+
6+
```
7+
CXXXXXXXYYYYZZZZ
8+
```
9+
10+
The identifier is divided into three fields.
11+
12+
Char Offset | Field | Size (bits) |Explanation
13+
-|-----|------|---------
14+
0 | C| 4 | Lead-in (ignore)
15+
1-7 | XXXXXXX | 28 | Ledger Sequence
16+
8-11 | YYYY | 16 | Transaction index (offset) within that ledger
17+
12-16 | ZZZZ | 16 | Network ID.
18+
19+
Reference implementations are available for several languages. Click below to dive in.
20+
21+
Language | Implementation
22+
-|-
23+
Javascript | [ctid.js](https://github.com/XRPLF/ctid/blob/main/ctid.js)
24+
Typescript | [ctid.ts](https://github.com/XRPLF/ctid/blob/main/ctid.ts)
25+
C++ | [ctid.cpp](https://github.com/XRPLF/ctid/blob/main/ctid.cpp)
26+
Python 3| [ctid.py](https://github.com/XRPLF/ctid/blob/main/ctid.py)
27+
PHP 5|[ctid.php](https://github.com/XRPLF/ctid/blob/main/ctid.php)
28+
29+
30+
### Function prototypes (pseudocode)
31+
In this repo there are several reference implementations available for various languages but they all use the same function model.
32+
```js
33+
function encodeCTID (
34+
ledger_seq : number,
35+
txn_index : number,
36+
network_id : number) -> string;
37+
```
38+
```js
39+
function decodeCTID (ctid : string or number) -> {
40+
ledger_seq : number,
41+
txn_index : number,
42+
network_id : number };
43+
```
44+
45+
### Mainnet example
46+
[This transaction](https://livenet.xrpl.org/transactions/D42BE7DF63B4C12E5B56B4EFAD8CBB096171399D93353A8A61F61066160DFE5E/raw) encodes in the following way:
47+
```js
48+
encodeCTID(
49+
77727448, // ledger sequence number the txn appeared in
50+
54, // `TransactionIndex` as per metadata
51+
0) // Network ID of mainnet is 0
52+
'C4A206D800360000'
53+
```
54+
55+
### Hooks testnet v3 example
56+
[This transaction](https://hooks-testnet-v3-explorer.xrpl-labs.com/tx/C4E284010276F8457C4BF96D0C534B7383087680C159F9B8C18D5EE876F7EFE7) encodes in the following way:
57+
```js
58+
encodeCTID(
59+
428986, // ledger sequence number the txn appeared in
60+
0, // `TransactionIndex` as per metadata
61+
21338) // Network ID of hooks v3 is 21338
62+
'C0068BBA0000535A'
63+
```

XLS-0037-concise-transaction-identifier-ctid/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
# Quickstart
1515

16-
If you are a developer and want to get started quickly with integrating CTID, please visit [the quickstart repo](https://github.com/xrplf/ctid).
16+
If you are a developer and want to get started quickly with integrating CTID, please visit [the quickstart](./QUICKSTART.md).
1717

1818
# Abstract
1919

@@ -98,11 +98,11 @@ CTIDs allow users to quickly and easily identify their transactions on a particu
9898

9999
To future-proof CTID identifiers, the parameters and their sizes and lifespans are considered:
100100

101-
| Field | Size (bits) | Limit (decimal) | Lifespan | Explanation |
102-
| ----------------- | ----------- | --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103-
| Ledger Index | 28 | 268,435,455 | 34 years from genesis | This field would otherwise be 32 bits but for the C lead-in nibble. We feel the easily identified C is more useful than an extremely long lifespan. |
101+
| Field | Size (bits) | Limit (decimal) | Lifespan | Explanation |
102+
| ----------------- | ----------- | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
103+
| Ledger Index | 28 | 268,435,455 | 34 years from genesis | This field would otherwise be 32 bits but for the C lead-in nibble. We feel the easily identified C is more useful than an extremely long lifespan. |
104104
| Transaction Index | 16 | 65,535 | ∞ / until there are more than 65,535 transactions per ledger | It is very unlikely there will be more than 65535 transactions per ledger in any XRPL Protocol Chain for a long time. If there are then those above this limit still exist but cannot be identified as CTID. |
105-
| Network ID | 16 | 65,535 | ∞ / until there are more than 65535 ports allowed in TCP | In XRPL Protocol Chains the Network ID should match the chosen peer port. Thus the natural limitation on Network ID is that of the TCP port (65536). |
105+
| Network ID | 16 | 65,535 | ∞ / until there are more than 65535 ports allowed in TCP | In XRPL Protocol Chains the Network ID should match the chosen peer port. Thus the natural limitation on Network ID is that of the TCP port (65536). |
106106

107107
### 2.2 Extensible
108108

@@ -178,7 +178,7 @@ yarn add xls-37d
178178
An example encoding routine in typescript follows:
179179

180180
```tsx
181-
import xls37d from 'xls-37d';
181+
import xls37d from "xls-37d";
182182

183183
const { ctid } = new xls37d.encode({
184184
networkId,
@@ -192,7 +192,7 @@ const { ctid } = new xls37d.encode({
192192
An example decoding routine in typescript follows:
193193

194194
```tsx
195-
import xls37d from 'xls-37d';
195+
import xls37d from "xls-37d";
196196

197197
const { networkId, lgrIndex, txnIndex } = new xls37d.decode(ctid);
198198
```

0 commit comments

Comments
 (0)