substrate_addr

Module for Substrate address encoding/decoding.

class SubstrateEd25519AddrDecoder

Bases: IAddrDecoder

Substrate address decoder class, based on ed25519 curve. It allows the Substrate address decoding.

static DecodeAddr(addr: str, **kwargs: Any) bytes

Decode a Substrate address to bytes.

Parameters:
  • addr (str) – Address string

  • ss58_format (int) – Expected SS58 format

Returns:

Public key bytes

Return type:

bytes

Raises:

ValueError – If the address encoding is not valid

class SubstrateEd25519AddrEncoder

Bases: IAddrEncoder

Substrate address encoder class, based on ed25519 curve. It allows the Substrate address encoding.

static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str

Encode a public key to Substrate address.

Parameters:
  • pub_key (bytes or IPublicKey) – Public key bytes or object

  • ss58_format (int) – SS58 format

Returns:

Address string

Return type:

str

Raised:

ValueError: If the public key is not valid

class SubstrateSr25519AddrDecoder

Bases: IAddrDecoder

Substrate address decoder class, based on sr25519 curve. It allows the Substrate address decoding.

static DecodeAddr(addr: str, **kwargs: Any) bytes

Decode a Substrate address to bytes.

Parameters:
  • addr (str) – Address string

  • ss58_format (int) – Expected SS58 format

Returns:

Public key bytes

Return type:

bytes

Raises:

ValueError – If the address encoding is not valid

class SubstrateSr25519AddrEncoder

Bases: IAddrEncoder

Substrate address encoder class, based on sr25519 curve. It allows the Substrate address encoding.

static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str

Encode a public key to Substrate address.

Parameters:
  • pub_key (bytes or IPublicKey) – Public key bytes or object

  • ss58_format (int) – SS58 format

Returns:

Address string

Return type:

str

Raised:

ValueError: If the public key is not valid

SubstrateEd25519Addr

alias of SubstrateEd25519AddrEncoder

SubstrateSr25519Addr

alias of SubstrateSr25519AddrEncoder