encodeKey method

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

Overrides the base class method to encode a public key as a Near Protocol address.

This method encodes a public key as a Near Protocol address. It expects the public key as a List

Parameters:

  • pubKey: The public key to be encoded as a Near Protocol address in the form of a List
  • kwargs: Optional keyword arguments (not used in this implementation).

Returns: A String representing the hexadecimal representation of the provided public key for the Near Protocol address.

Implementation

@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
  /// Validate and get the Ed25519 public key.
  final pubKeyObj = AddrKeyValidator.validateAndGetEd25519Key(pubKey);

  /// Encode the public key as a hexadecimal representation and remove the '0x' prefix.
  return StringUtils.strip0x(BytesUtils.toHexString(pubKeyObj.compressed))
      .substring(2);
}