Solana Namespace - Chains
Author | Antoine Herzog, Josh Hundley |
---|---|
Discussions-To | https://github.com/ChainAgnostic/CAIPs/pull/60 |
Status | Draft |
Type | Standard |
Created | 2021-08-03 |
Updated | 2023-03-27 |
Requires | CAIP-2 |
Withdrawal reason | CAIP-28 |
Table of Contents
CAIP-2
For context, see the CAIP-2 specification.
Rationale
In CAIP-2 a general blockchain identification scheme is defined. This is the implementation of CAIP-2 for Solana. Blockchains in the “solana” namespace are validated by their genesis hash; each blockchain is maintained by a “Cluster” of nodes, with its own gossip entrypoint and other endpoints. These genesis hashes require no transformations to be used as conformant CAIP-2 references aside from concatenating their first 32 characters.
Syntax
The namespace “solana” refers to the Solana open-source blockchain platform.
Reference Definition
The definition for this namespace will use the genesisHash
as an identifier
for different Solana chains. The method for calculating the chain ID is as
follows with pseudo-code:
truncate(genesisHash, 32)
Resolution Method
To resolve a blockchain reference for the Solana namespace, make a JSON-RPC
request to the RPC Endpoints of a blockchain node with method
getGenesisHash
, for example:
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "getGenesisHash"
}
// Response
{
"id": 1,
"jsonrpc": "2.0",
"result": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
}
The response will return as a value for the result a 44-character Base58btc-encoded hash for the block with height 0 that should be truncated to its first 32 characters to be CAIP-2 compatible.
Backwards Compatibility
Not applicable
Test Cases
This is a list of manually composed examples
# Solana Mainnet
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
# Solana Devnet
solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
# Solana Testnet
solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z
References
- RPC Endpoints - RPC reference in Solana official documentation
- Solana core rust crate on crates.io
- Base58btc encoding “alphabet” (i.e. character-set)
Copyright
Copyright and related rights waived via CC0.
Citation
Please cite this document as:
Antoine Herzog, Josh Hundley, "namespaces/solana-caip2: Solana Namespace - Chains [DRAFT]," Chain Agnostic Namespaces, solana-caip2, August 2021 / March 2023. [Online serial]. Available: https://github.com/ChainAgnostic/namespaces/solana-caip2.md