Polkadot Namespace - Addresses

Author ["Pedro Gomes, "Joshua Mir, "Shawn Tabrizi, "Juan Caballero, "Antonio Antonino
Discussions-To https://github.com/ChainAgnostic/CAIPs/issues/13
Status Draft
Type Standard
Created 2020-04-01
Updated 2023-02-22
Requires CAIP-2, CAIP-10
Withdrawal reason CAIP-13

CAIP-10

For context, see the CAIP-10 specification.

Rationale

Regardless of the byte-length of the underlying private key, Polkadot addresses are typically expressed as a multiaddress in Polkadot development, encoded in a Base58 format based on the Bitcoin Base58-check format, with a few modifications to address the multi-chain context Polkadot operates in. Specifically, each network defines its own network identifier, which is then included in the Base58 encoding process so that, for most networks, all addresses have the same prefix. An SS58 registry is maintained by the Polkadot blockchain teams, and each prefix is uniquely assigned to a chain on a first-come-first-served basis. A more in-depth description of address encoding can be found in the Polkadot address documentation.

As a consequence, a given private-public keypair will yield a different account on each chain where it is used, so de-duplicating Polkadot accounts in a multi-chain context requires decoding addresses to raw public keys and make decisions based on that.

As the default multiaddress was used as the basis for the account_address segment of Polkadot CAIP-10s, all other possible expressions are out of scope of this specification. Similarly, recovery of chain ID from derived account type or validation of addresses using the included checksum are both out of scope, although both are specified in the Polkadot address documentation.

Syntax

Because address length is dependent on the network, and other components must be checked such as the address’ checksum, there is no simple way to verify an address using only a regex. Instead, there are libraries for address validation, encoding, and decoding support, such as the polkadot-js library.

Nevertheless, if a regex were to be used, it should match on addresses that are either 47 or 48 character long, and only containing characters from the Base58btc alphabet:

[1-9A-HJ-NP-Za-km-z]{47,48}

Test Cases

This is a list of example addresses generated from the same public key, composed using the Subscan address converter; the 1-byte SS58 prefix is given in decimal for clarity, as listed in the SS58 registry:

# Public key (in HEX format)
0xd6a3105d6768e956e9e5d41050ac29843f98561410d3a47f9dd5b3b227ab8746

# Polkadot (SS58 prefix = 0)
polkadot:91b171bb158e2d3848fa23a9f1c25182:15rRgsWxz4H5LTnNGcCFsszfXD8oeAFd8QRsR6MbQE2f6XFF

# Kusama (SS58 prefix = 2)
polkadot:b0a8d493285c2df73290dfb7e61f870f:HRkCrbmke2XeabJ5fxJdgXWpBRPkXWfWHY8eTeCKwDdf4k6

# KILT Spiritnet (SS58 prefix = 38)
polkadot:a0453819cbf8b4df9423a5cd601f546c:4smVWa6Hb7WhGh9zgqdAE86p5eZyj8BQJ9Uro4o2zidBnmfX

# Karura (SS58 prefix = 8)
polkadot:baf5aabe40646d11f0ee8abbdc64f4a4:t9hkorC4PGtaw25WsESu684h6HA5dHndvrvLZW174nZM5MR

# Crust Network (SS58 prefix = 66)
polkadot:8b404e7ed8789d813982b9cb4c8b664c:cTMC4XwPfBn3bz8kFaVTjaWdkQi6agzMxS11e8hpPHhqLrhGs

References

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

["Pedro Gomes, "Joshua Mir, "Shawn Tabrizi, "Juan Caballero, "Antonio Antonino, "namespaces/polkadot-caip10: Polkadot Namespace - Addresses [DRAFT]," Chain Agnostic Namespaces, polkadot-caip10, April 2020 / February 2023. [Online serial]. Available: https://github.com/ChainAgnostic/namespaces/polkadot-caip10.md