|
| 1 | +--- |
| 2 | +namespace-identifier: partisia-caip2 |
| 3 | +title: Partisia Blockchain - Networks |
| 4 | +author: Partisia Blockchain Foundation |
| 5 | +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/130 |
| 6 | +status: Draft |
| 7 | +type: Standard |
| 8 | +created: 2024-10-22 |
| 9 | +--- |
| 10 | + |
| 11 | +<!--You can leave these HTML comments in your merged CAIP and delete the |
| 12 | + visible duplicate text guides, they will not appear and may be helpful to |
| 13 | + refer to if you edit it again. This is the suggested template for new CAIPs. |
| 14 | + Note that an CAIP number will be assigned by an editor. When opening a pull |
| 15 | + request to submit your EIP, please use an abbreviated title in the |
| 16 | + filename, `caipX.md`, all lowercase, no `-` between the CAIP and its |
| 17 | + number.--> |
| 18 | + |
| 19 | +# CAIP-2 |
| 20 | + |
| 21 | +*For context, see the [CAIP-2][] specification.* |
| 22 | + |
| 23 | +<!--"If you can't explain it simply, you don't understand it well enough." Provide a simplified and layman-accessible explanation of the CAIP.--> |
| 24 | + |
| 25 | +CAIP-2 defines a general identification scheme for blockchains. This is the implementation of CAIP-2 |
| 26 | +for Partisia Blockchain. |
| 27 | + |
| 28 | +## Rationale |
| 29 | + |
| 30 | +<!--A short (~200 word) description of the technical issue being addressed.--> |
| 31 | +Partisia Blockchain consists of multiple networks: mainnet, testnet and potentially other private |
| 32 | +networks. |
| 33 | +Each network has a unique chain id that can be used to identify the network. |
| 34 | + |
| 35 | +The Partisia Blockchain networks are identified by the `partisia` namespace prefix, followed by the |
| 36 | +chain id of the particular network. |
| 37 | + |
| 38 | +## Syntax |
| 39 | + |
| 40 | +The chain id of Partisia Blockchain is a human-readable identifier of the particular chain. Due to |
| 41 | +the character limitations of CAIP-2, all characters that are not allowed in the CAIP-2 characterset (i.e., |
| 42 | +`[^-_a-zA-Z0-9]`) are replaced with `_`. |
| 43 | + |
| 44 | +### Resolution Mechanics |
| 45 | + |
| 46 | +To resolve the blockchain reference for a Partisia Blockchain chain, a GET request can be made to a |
| 47 | +running reader node on the path `/blockchain/chainId`. This will return a JSON object with the key |
| 48 | +`chainId` that are the human-readable chain id of this chain. |
| 49 | + |
| 50 | +For example: |
| 51 | + |
| 52 | +``` |
| 53 | +# Request |
| 54 | +curl -s https://reader.partisiablockchain.com/blockchain/chainId |
| 55 | +
|
| 56 | +#Response |
| 57 | +{ |
| 58 | + "chainId": "Partisia Blockchain" |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +To convert this to a valid CAIP-2 identifier one need only replace any characters not allowed by the |
| 63 | +specification and prefix with the namespace. |
| 64 | + |
| 65 | +An example of the conversion using curl and jq: |
| 66 | +```bash |
| 67 | +curl -s https://reader.partisiablockchain.com/blockchain/chainId | jq -r '.chainId | "partisia:" +gsub("[^a-zA-Z0-9]"; "_")' # Outputs: partisia:Partisia_Blockchain |
| 68 | +``` |
| 69 | + |
| 70 | +### Backwards Compatibility |
| 71 | + |
| 72 | +Not applicable |
| 73 | + |
| 74 | +## Test Cases |
| 75 | + |
| 76 | +``` |
| 77 | +# Partisia Blockchain mainnet |
| 78 | +partisia:Partisia_Blockchain |
| 79 | +
|
| 80 | +# Partisia Blockchain testnet |
| 81 | +partisia:Partisia_Blockchain_Testnet |
| 82 | +``` |
| 83 | + |
| 84 | +## References |
| 85 | + |
| 86 | +- [Partisia Blockchain Developer Documentation][] |
| 87 | +- [CAIP-2][] |
| 88 | + |
| 89 | +[Partisia Blockchain Developer Documentation]: https://partisiablockchain.gitlab.io/documentation/index.html |
| 90 | +[CAIP-2]: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md |
| 91 | + |
| 92 | +## Copyright |
| 93 | + |
| 94 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
0 commit comments