Caip

object Caip

The CAIP identifiers WalletConnect speaks, and the one place Canton party ids are reconciled with them.

WalletConnect names a chain as namespace:reference (CAIP-2) and an account as namespace:reference:address (CAIP-10). A Canton network id is already CAIP-2 (canton:localnet), so it doubles as the chain id. The friction is the account address: a party id is hint::1220<fingerprint>, and the :: — plus any _ in a hint — falls outside the CAIP-10 address charset ([-.%a-zA-Z0-9]). So a party is percent-encoded into the address segment, and recovered by the inverse. canton is WalletConnect's namespace for Canton (canton:<network-id>, operator-defined), and this percent-encoded account (:: ->%3A%3A) matches its published Canton chain support.

Properties

Link copied to clipboard

WalletConnect namespace for Canton.

Functions

Link copied to clipboard
fun account(chainId: String, partyId: String): String

Builds the CAIP-10 account (chain:encodedParty) a session advertises.

Link copied to clipboard
fun chainId(networkId: String): String

Validates a CAIP-2 chain id and returns it. A Canton networkId is already CAIP-2, so this guards a mistyped value before it reaches a relay rather than transforming anything.

Link copied to clipboard
fun decodeParty(address: String): String

Recovers a party id from a CAIP-10 address segment.

Link copied to clipboard
fun encodeParty(partyId: String): String

Percent-encodes a party id into a CAIP-10 address segment: every UTF-8 byte outside [-.A-Za-z0-9] becomes %XX (upper-case), so :: → %3A%3A and _ → %5F. decodeParty is the inverse.

Link copied to clipboard

Extracts the party id from a CAIP-10 account. The address segment carries no literal : (they are percent-encoded), so the last : splits chain from address unambiguously.