From d947f749003cce8196b5108c403bc903cc53e26d Mon Sep 17 00:00:00 2001 From: Anton Dalgren Date: Fri, 24 Feb 2023 11:46:51 +0100 Subject: [PATCH] feat: Added XRPL namespace along with CAIP-2 and CAIP-10 standard. (#1) --- xrpl/README.md | 29 +++++++++++++ xrpl/caip10.md | 72 +++++++++++++++++++++++++++++++ xrpl/caip2.md | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 xrpl/README.md create mode 100644 xrpl/caip10.md create mode 100644 xrpl/caip2.md diff --git a/xrpl/README.md b/xrpl/README.md new file mode 100644 index 00000000..7ace4006 --- /dev/null +++ b/xrpl/README.md @@ -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. diff --git a/xrpl/caip10.md b/xrpl/caip10.md new file mode 100644 index 00000000..4027da28 --- /dev/null +++ b/xrpl/caip10.md @@ -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 232 + +### 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/). + diff --git a/xrpl/caip2.md b/xrpl/caip2.md new file mode 100644 index 00000000..18f3f491 --- /dev/null +++ b/xrpl/caip2.md @@ -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/).