encodeKey method

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

Encodes a public key as a Tron address.

This method takes a public key and encodes it as a Tron address by first converting it to an Ethereum address and then prefixing it with the Tron address prefix. The resulting address is encoded using the Base58 encoding.

Parameters:

  • pubKey: The public key to be encoded.
  • kwargs: Optional arguments, if needed.

Returns: A Tron address encoded as a Base58 string.

Implementation

@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
  final String ethAddr = EthAddrEncoder().encodeKey(pubKey).substring(2);
  return Base58Encoder.checkEncode(List<int>.from([
    ...BytesUtils.fromHexString(CoinsConf.tron.params.addrPrefix!),
    ...BytesUtils.fromHexString(ethAddr)
  ]));
}