TronAddress.fromPublicKey constructor

TronAddress.fromPublicKey(
  1. List<int> keyBytes
)

Factory method to create a TronAddress from a Tron public key represented as a list of integers

Implementation

factory TronAddress.fromPublicKey(List<int> keyBytes) {
  try {
    final toAddress = TrxAddrEncoder().encodeKey(keyBytes);
    final decode = TrxAddrDecoder().decodeAddr(toAddress);
    return TronAddress._(toAddress,
        BytesUtils.toHexString([...TrxAddressUtils.prefix, ...decode]));
  } catch (e) {
    throw MessageException("invalid tron public key",
        details: {"input": BytesUtils.toHexString(keyBytes)});
  }
}