|
| 1 | +--- |
| 2 | +namespace-identifier: sui-caip2 |
| 3 | +title: Sui Namespace - Chains |
| 4 | +author: William Robertson (@williamrobertson13) |
| 5 | +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/146 |
| 6 | +status: Draft |
| 7 | +type: Informational |
| 8 | +created: 2025-06-18 |
| 9 | +updated: 2025-06-18 |
| 10 | +--- |
| 11 | + |
| 12 | +# CAIP-2 |
| 13 | + |
| 14 | +_For context, see the [CAIP-2][] specification._ |
| 15 | + |
| 16 | +## Introduction |
| 17 | + |
| 18 | +The Sui namespace in CAIP-2 defines chain identifiers based on the **genesis checkpoint digest**, a cryptographically unique and immutable value derived from the first checkpoint of a Sui network. This ensures that identifiers are stable, verifiable, and unambiguous. |
| 19 | + |
| 20 | +## Specification |
| 21 | + |
| 22 | +### Semantics |
| 23 | + |
| 24 | +A valid CAIP-2 identifier in the Sui namespace takes the form: |
| 25 | + |
| 26 | +``` |
| 27 | +sui:<genesis_checkpoint_digest> |
| 28 | +``` |
| 29 | + |
| 30 | +Where `<genesis_checkpoint_digest>` is the first 4 bytes (8 hex characters) of the network’s genesis checkpoint digest. |
| 31 | + |
| 32 | +### Syntax |
| 33 | + |
| 34 | +#### Regular Expression |
| 35 | + |
| 36 | +``` |
| 37 | +^sui:[0-9a-fA-F]{8}$ |
| 38 | +``` |
| 39 | + |
| 40 | +#### Example |
| 41 | + |
| 42 | +``` |
| 43 | +sui:35834a8a |
| 44 | +``` |
| 45 | + |
| 46 | +### Resolution Mechanics |
| 47 | + |
| 48 | +To resolve a CAIP-2 chain identifier, clients query a trusted full node associated with the specified network. While the `suix_getChainIdentifier` JSON-RPC method is commonly used for this purpose, resolution is not limited to JSON-RPC. Other interfaces, such as GraphQL, may also support retrieving the corresponding genesis checkpoint digest. |
| 49 | + |
| 50 | +**Sample request:** |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "jsonrpc": "2.0", |
| 55 | + "id": 1, |
| 56 | + "method": "suix_getChainIdentifier", |
| 57 | + "params": [] |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +**Sample response:** |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "jsonrpc": "2.0", |
| 66 | + "id": 1, |
| 67 | + "result": "35834a8a" |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Rationale |
| 72 | + |
| 73 | +This approach advocates for the exclusive use of unambiguous chain identifiers for identifying Sui chains in CAIP-2 format. |
| 74 | + |
| 75 | +While human-readable identifiers like `sui:mainnet` or `sui:testnet` are intuitive, they are not stable over time. Networks like testnet and devnet may be reset by Sui maintainers, resulting in a new genesis state. When this happens, the associated digest changes, meaning the underlying chain is no longer the same, even if the CAIP-2 identifier remains unchanged. |
| 76 | + |
| 77 | +Using the digest-based identifier directly avoids this ambiguity by ensuring all references point to a specific, verifiable chain instance. This eliminates reliance on potentially outdated or re-used labels and simplifies validation logic. |
| 78 | + |
| 79 | +By relying solely on unambiguous identifiers, we prioritize long-term compatibility, security, and correctness. This ensures that clients consistently interact with the intended chain, even as network environments evolve. |
| 80 | + |
| 81 | +### Backwards Compatibility |
| 82 | + |
| 83 | +There are no legacy identifiers or alternate forms for Sui chains. |
| 84 | + |
| 85 | +## Test Cases |
| 86 | + |
| 87 | +Below are manually composed examples: |
| 88 | + |
| 89 | +``` |
| 90 | +# CAIP-2 Chain ID for Mainnet** |
| 91 | +sui:35834a8a |
| 92 | +
|
| 93 | +# CAIP-2 Chain ID for Testnet** |
| 94 | +sui:4c78adac |
| 95 | +
|
| 96 | +# CAIP-2 Chain ID for Devnet** |
| 97 | +sui:aba3e445 |
| 98 | +``` |
| 99 | + |
| 100 | +## References |
| 101 | + |
| 102 | +- [Sui Docs] - Developer documentation and concept overviews for building on Sui. |
| 103 | +- [Sui RPC] - Reference documentation for interacting with Sui networks via RPC. |
| 104 | +- [Sui GitHub] - Official GitHub repository for the Sui smart contract platform. |
| 105 | +- [CAIP-2] - Chain ID Specification. |
| 106 | + |
| 107 | +[Sui Docs]: https://docs.sui.io/ |
| 108 | +[Sui RPC]: https://docs.sui.io/references/sui-api |
| 109 | +[Sui GitHub]: https://github.com/MystenLabs/sui |
| 110 | +[CAIP-2]: https://chainagnostic.org/CAIPs/caip-2 |
| 111 | + |
| 112 | +## Copyright |
| 113 | + |
| 114 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
0 commit comments