0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

What Is a CAIP-2 Chain Identifier? Format for Wallets

0
Posted at

A CAIP-2 chain identifier names a blockchain as a namespace and reference, so EVM networks use the form eip155:chain-id.

  • Namespace: identifies the chain family, such as eip155.
  • Reference: identifies a chain within that family, such as Ethereum mainnet’s 1.
  • Result: Ethereum mainnet is eip155:1.

How do you build a CAIP-2 identifier from an EVM chain ID?

For an EVM network, take its decimal Chain ID and prefix it with the eip155: namespace. Base has Chain ID 8453, so its CAIP-2 identifier is eip155:8453. The reference is the decimal chain ID published for that network, not its name or RPC endpoint.

Chainlist provides EVM network details including chain IDs. Use the value for the network you intend to support; to learn how to find a Chainlist network’s chain ID, see the article on locating that value. Then add the eip155: prefix to form the CAIP-2 identifier.

CAIP-2 comes from the Chain Agnostic Improvement Proposals by ChainAgnostic. Its namespace-and-reference structure lets integrations represent chains from different ecosystems in one format. An EVM chain uses eip155; Bitcoin uses the bip122 namespace, with a reference keyed by the genesis hash. The namespace tells an integration how to interpret the reference, so a bare number such as 1 is not interchangeable with eip155:1.

Related

CAIP-2 vs plain EIP-155 chain ID

A plain EIP-155 Chain ID is the numeric value used to identify an EVM chain, while a CAIP-2 identifier includes that value and its namespace. For Ethereum mainnet, the Chain ID is 1 and the CAIP-2 identifier is eip155:1. They refer to the same network at different levels of specificity. An integration that expects CAIP-2 needs the complete identifier; sending only 1 omits the chain family.

How WalletConnect namespaces list chains

WalletConnect v2 session namespaces declare supported chains with CAIP-2 identifiers. A dApp can request a chain such as eip155:8453, and the wallet checks whether it supports that chain for the session. If the wallet lacks the requested chain, the session may be rejected or the integration may surface an unsupported-chain error.

CAIP-10 builds on CAIP-2 by appending an account address: eip155:1:0xab.... The chain portion identifies where the account is being used; the address identifies the account on that chain. Therefore, one EOA used on Ethereum and Base has two distinct CAIP-10 account identifiers in a WalletConnect session, even when the address string is the same. Treating those entries as one account would lose the chain context needed to interpret a request or permission.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?