Polkadart Logo
Keyring Signer

SS58 Address Format

The SS58 address format is the standard for encoding and decoding addresses in the Polkadot ecosystem. It is based on the Bitcoin Base-58-check encoding, with a few modifications designed for the needs of Polkadot-based chains. With this format it is possible to identity to which network a given address belongs, and to encode and decode addresses for different networks.

The SS58 address format is the standard for encoding and decoding addresses in the Polkadot ecosystem. It is based on the Bitcoin Base-58-check encoding, with a few modifications designed for the needs of Polkadot-based chains. With this format it is possible to identity to which network a given address belongs, and to encode and decode addresses for different networks.

Installation

Add the following to your pubspec.yaml file:

pubspec.yaml
dependencies:
  ss58: ^1.1.3

Get the dependencies by running:

dart pub get

Usage

Decoding an Address

final address = Address.decode('1zugcag7cJVBtVRnFxv5Qftn7xKAnR6YJ9x4x3XLgGgmNnS');

Registry Info by Prefix

// get registry info of given `prefix`

final polkadotRegistry = Codec.registry.getByPrefix(0);

print('polkadot registry: $polkadotRegistry');

Decoding Substrate Address

// decoding substrate address

final String originalEncodedAddress = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';

final List<int> decodedBytes = Codec.fromNetwork('substrate').decode(originalEncodedAddress);

print('Substrate address bytes: $decodedBytes');

Encoding bytes to produce address

// Encoding the decodedBytes to produce back encodedAddress.

final int substrateAddressPrefix = 42;

final encodedAddress = Codec(substrateAddressPrefix).encode(decodedBytes);

print(encodedAddress);