encodeKey method

  1. @override
String encodeKey(
  1. List<int> pubKey, [
  2. Map<String, dynamic> kwargs = const {}
])
override

Encodes a public key into a Substrate address.

This method takes a public key as a List

Parameters:

  • pubKey: The public key to be encoded as a Substrate address.
  • kwargs: Optional keyword arguments (e.g., 'ss58_format') for customization.

Returns: A String representing the Substrate address encoded from the provided public key.

Throws:

  • FormatException if the provided SS58 format is invalid or if the public key is not a valid sr25519 key.

Implementation

@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
  AddrKeyValidator.validateAddressArgs<int>(kwargs, "ss58_format");
  final int ss58Format = kwargs["ss58_format"];
  AddrKeyValidator.validateAndGetSr25519Key(pubKey);
  return _SubstrateAddrUtils.encode(pubKey, ss58Format);
}