Skip to content

Latest commit

 

History

History
 
 

ss58

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@subsquid/ss58

SS58 registry and codec.

Usage

import * as ss58 from "@subsquid/ss58"

ss58.registry.get('kusama') // => {prefix: 2, network: 'kusama', ...}
ss58.registry.get(2) // => {prefix: 2, network: 'kusama', ...}

ss58.codec('kusama').encode(rawAddressBytes) // => EXtQYFeY2...
ss58.codec(2).encode(rawAddressBytes) // Same as above

ss58.codec('kusama').decode('EXtQYFeY2...') // => rawAddressBytes
ss58.codec('kusama').decode(polkadotAddress) // => throws error

let address = ss58.decode('EXtQYFeY2ivDsfazZvGC9aG87DxnhWH2f9kjUUq2pXTZKF5')
address.prefix // => 2 (address type)
address.bytes  // => Uint8Array of raw address bytes
ss58.encode(address) // => EXtQYFeY2ivDsfazZvGC9aG87DxnhWH2f9kjUUq2pXTZKF5