CAIP-50: Multi-Chain Account ID Specification


Metadata
Status: DraftStandardCreated: 2020-06-10
Authors
Joel Torstensson (@oed), Pedro Gomes (@pedrouid)
Requires

Simple Summary


CAIP-50 defines a way to identify blockchain account addresses uniquely across multiple blockchains

Abstract


This proposal aims to facilitate using unique address for accounts on multiple blockchain systems using a multi-codec format that encodes variable integer for chain identifiers complaint with CAIP-2 blockchain id specification. This is useful for both decentralized applications and wallets to communicate user accounts for multiple chains using unique identifiers which are machine veriable and can be decoded to identify the original address and chainId encoded. This proposal aims to standardize these identifiers for accounts to allow inteoperability for multi-chain applications.

Motivation


The motivation for this proposal came from different feedback received from the adoption of CAIP-10 and tackles these to provide a significant improvement in more efficient communication of these identifiers using smaller byte footprint while preserving uniqueness and interoperability.

Specification


In this specifiation we define the Multi-Chain Account Id or MACI for short which is a compactly encoded account identifier that is contextual to a blockchain using a CAIP-2 chainId.

Syntax


Semantics

  • multibase_prefix - the prefix which defines which multibase is used to encode the bytes, z for base58btc
  • mcai_code - a number registered on the multicodec table, makes the multi-chain account id upgradable, encoded as varint
  • chain_namespace - see table below, encoded as varint
  • id_size - the length in bytes of the chain_id, encoded as varint
  • chain_id - the chain id, encoding is defined by the chain namespace
  • address_size - the length of the address, encoded as varint
  • address - the address itself, encoding is defined by the chain namespace
  • parity_byte - a checksum byte, see section below

MCAI multicodec

Should be a number registered on the multicodec table. In the examples below we use 0xCA but this is subject to change.

Chain namespaces

Each blockchain namespace needs to be properly defined with a registry table:

Registry Table

Namespacecode
bip1220x00
eip1550x01
cosmos0x02
polkadot0x03
filecoin0x04
lip90x05
eosio0x06
tezos0x07

BIP122 Namespace (CAIP-4)

Chain ID: Convert from hex to bytes

Address: Convert from base58btc to bytes

Example:

In the exammple below we encode 128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6 on bitcoin mainnet. This means that we use chain_id = 000000000019d6689c085ae165831e93


EIP155 Namespace (CAIP-3)

Chain ID: Convert from integer to bytes

Address: Convert from hex to bytes

Example:

In the exammple below we encode 0xde30da39c46104798bb5aa3fe8b9e0e1f348163f on ethereum mainnet. This means that we use chain_id = 1


Cosmos Namespace (CAIP-5)

  • TODO

Polkadot Namespace (CAIP-13)

  • TODO

Filecoin Namespace (CAIP-23)

  • TODO

LIP9 Namespace (CAIP-6)

  • TODO

EOSIO Namespace (CAIP-7)

  • TODO

Tezos Namespace (CAIP-26)

  • TODO

Parity byte

Using the algorithm described on Wikipedia: checksums. XOR each byte word in the mcai, the resulting byte is the parity byte.

Making MCAI human readable

We could easily build tools and UIs that decompose the encoded mcai similar to this: https://cid.ipfs.io/#bagcqcera6wh5laey5njuo2weun46wv4cn2jlbn6qio6mt3bwian4kbp76tdq

Implementation

Below is a PoC implementation in javascript


Test Cases

This is a list of manually composed examples comparing CAIP-10 and CAIP-50 identifiers


Links


Copyright


Copyright and related rights waived via CC0.