Skip to content

Ss58

SS58 is a simple address format designed for Substrate based chains. Encoding/decoding according to specification on https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)

ss58_decode(address: str, valid_ss58_format: Optional[int] = None) -> str

Decodes given SS58 encoded address to an account ID

Parameters:

Name Type Description Default
address str required
valid_ss58_format Optional[int] None

Returns:

Type Description
Decoded string AccountId

ss58_encode(address: Union[str, bytes], ss58_format: int = 42) -> str

Encodes an account ID to an Substrate address according to provided address_type

Parameters:

Name Type Description Default
address Union[str, bytes] required
ss58_format int 42

Returns:

Type Description
str

ss58_encode_account_index(account_index: int, ss58_format: int = 42) -> str

Encodes an AccountIndex to an Substrate address according to provided address_type

Parameters:

Name Type Description Default
account_index int required
ss58_format int 42

Returns:

Type Description
str

ss58_decode_account_index(address: str, valid_ss58_format: Optional[int] = None) -> int

Decodes given SS58 encoded address to an AccountIndex

Parameters:

Name Type Description Default
address str required
valid_ss58_format Optional[int] None

Returns:

Type Description
Decoded int AccountIndex

is_valid_ss58_address(value: str, valid_ss58_format: Optional[int] = None) -> bool

Checks if given value is a valid SS58 formatted address, optionally check if address is valid for specified ss58_format

Parameters:

Name Type Description Default
value str required
valid_ss58_format Optional[int] None

Returns:

Type Description
bool

get_ss58_format(ss58_address: str) -> int

Returns the SS58 format for given SS58 address

Parameters:

Name Type Description Default
ss58_address str required

Returns:

Type Description
int