Skip to content

Commit

Permalink
feat: Added XRPL namespace along with CAIP-2 and CAIP-10 standard. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
antondalgren committed Feb 24, 2023
1 parent 76841ee commit d947f74
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 0 deletions.
29 changes: 29 additions & 0 deletions xrpl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
namespace-identifier: xrpl
title: XRP Ledger Namespace
author: Anton Dalgren (@antondalgren)
status: Draft
type: Informational
created: 2023-02-23
requires: ["CAIP-2", "CAIP-10"]
---

# Namespace for XRP Ledger

This document defines the applicability of CAIP schemes to the blockchains of
the XRP Ledger ecosystem.

## Syntax

The namespace `xrpl` refers to the XRP Ledger ecosystem, including private
networks.

## References

- [XRP Ledger documentation](https://xrpl.org/docs.html)
- [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md)
- [CAIP-10](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md)

## Rights

Copyright and related rights waived via CC0.
72 changes: 72 additions & 0 deletions xrpl/caip10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
namespace-identifier: xrpl-caip10
title: XRP Ledger Namespace - Addresses
author: Anton Dalgren (@antondalgren)
status: Draft
type: Standard
created: 2023-02-23
requires: ["CAIP-2", "CAIP-10"]
---

# CAIP-10

*For context, see the [CAIP-10][] specification.*

## Rationale

In CAIP-10, a string-based general account address scheme is defined. XRPL addresses are identified by an address in the XRP Ledger's base58 encoding. The address is derived from an account's master public key. An XRPL address is a string with the following characteristics.
* It is between 25 and 35 characters long.
* It starts with the character `r`
* It uses alpanumerical characters excluding number `0`, lowercase letter `"l"` and capital letters `["O", "I"]`.
* It is case-sensitive
* It includes a 4-byte checksum making the probabilty of generating a valid address from random characters approximately 1 in 2<sup>32</sup>

### Syntax

The `account_id` is a case-sensitive string in the form:

```
account_id: chain_id + ":" + account_address
chain_id: See [CAIP-2][]
account_address: r[1-9a-hj-zA-HJ-NP-Z]{24,34}
```

### Semantics

The `chain_id` is specified by the [CAIP-2][] which describes the blockchain id.
The `account_address` is the address to an account on the XRPL.

## Test Cases

This is a list of manually composed examples

```
# Livenet address
xrpl:0:r4FTvnahbUfhe1WK2EK5Jz4cNvdFvT8Dzt
# Testnet address
xrpl:1:rEBakx2WdNsmRb5tm5KmhsqKAqvLJrRoiU
# Devnet address
xrpl:2:rUgna78QFFeixu8v9ZqwtViWnknXYtHG2X
```

## Backwards Compatibility

Not applicable

## References

- [XRPL Address Definition][] - The explanation of a XRPL Address, what it consists of and what limitations it has.
- [XRPL Base58 Encoding][] - Explains how a public key is encoded to a XRPL address.


[CAIP-2]: ./caip2.md
[CAIP-10]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md
[XRPL Address Definition]: https://xrpl.org/accounts.html#addresses
[XRPL Base58 Encoding]: https://xrpl.org/base58-encodings.html

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

113 changes: 113 additions & 0 deletions xrpl/caip2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
namespace-identifier: xrpl-caip2
title: XRP Ledger Namespace - Chains
author: Anton Dalgren (@antondalgren)
status: Draft
type: Standard
created: 2023-02-23
requires: ["CAIP-2"]
---

# CAIP-2.

*For context, see the [CAIP-2][] specification.*

## Rationale

The namespace `xrpl` refers to the XRP Ledger ecosystem, including its alternative testing and development networks.

The XRP Ledger ecosystem consists of several different blockchains. There is one production network called `livenet` where all business on the XRP Ledger takes place, a testing network called `testnet` for stable releases and a development network called `devnet` for beta releases. There are also some preview networks for particularly large network changes. The networks are identified by a numerical `network_id`.

An identifier for an XRPL chain consists of the `xrpl` namespace prefix followed by the chains `network_id`; `xrpl:network_id`.


## Syntax

A network id in the XRP Ledger ecosystem is defined as an unsigned integer ranging from 0 to 4294967295.


### Resolution Method

To resolve a network reference for a XRPL network, POST a RPC request to the XRPL node with endpoint `/` for example:

```jsonc
// Request
curl --location --request POST "https://xrplcluster.com/" \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "server_info",
"params": [ ]
}'
// Response
{
"result": {
"info": {
"build_version": "1.9.4",
"complete_ledgers": "32570-77992447",
"hostid": "LEST",
"initial_sync_duration_us": "328508164",
"io_latency_ms": 1,
"jq_trans_overflow": "9048",
"last_close": {
"converge_time_s": 3.001,
"proposers": 34
},
"load_factor": 1,
"network_id": 0,
"peer_disconnects": "29",
"peer_disconnects_resources": "0",
"peers": 23,
"pubkey_node": "n9KQK8yvTDcZdGyhu2EGdDnFPEBSsY5wEgpU5GgpygTgLFsjQyPt",
"server_state": "full",
"server_state_duration_us": "35758622131",
"state_accounting": {"..."},
"time": "2023-Feb-23 13:24:41.285216 UTC",
"uptime": 700794,
"validated_ledger": {"..."},
"validation_quorum": 28
},
"status": "success"
}
}
```
The response will return a JSON object which will include server information.

The network reference can be retrieved from the field `response.info.network_id` in the response of the `server_info` RPC request.

### Backwards Compatibility

Not applicable

## Test Cases

This is a list of manually composed examples

```
# Livenet
xrpl:0
# Testnet
xrpl:1
# Devnet
xrpl:2
# AMM - Devnet
xrpl:25
```

## References

- [XRPL Networks](https://xrpl.org/parallel-networks.html) - Description of the different XRPL networks.
- [XRPL Public Nodes](https://xrpl.org/public-servers.html) - Public nodes for the different XRPL networks.
- [XRPL Server Info Request](https://xrpl.org/server_info.html) -
RPC request to get the network_id.
- [XRPL Documentation](https://xrpl.org/docs.html)
- [XRPL Network ID](https://github.com/XRPLF/rippled/blob/8f514937a41eba90d98fb99daf938925527f0c44/cfg/rippled-example.cfg#L818-L820) - The definition of the network_id value.
- [CAIP-2]

[CAIP-2]: https://chainAgnostic.org/CAIPS/caip-2

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 comments on commit d947f74

Please sign in to comment.