@subsquid/ss58
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

@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  // => 0x569d... (hex encoded raw address bytes)
ss58.encode(address) // => EXtQYFeY2ivDsfazZvGC9aG87DxnhWH2f9kjUUq2pXTZKF5

Readme

Keywords

none

Package Sidebar

Install

npm i @subsquid/ss58

Weekly Downloads

166

Version

2.0.2

License

GPL-3.0-or-later

Unpacked Size

98.7 kB

Total Files

29

Last publish

Collaborators

  • subsquid