abiEncode method

  1. @override
EncoderResult abiEncode(
  1. AbiParameter params,
  2. SolidityAddress input
)
override

Encodes a BaseHexAddress to ABI-encoded bytes. The resulting bytes include Ethereum or Tron address bytes

Implementation

@override
EncoderResult abiEncode(AbiParameter params, SolidityAddress input) {
  final bytes = List<int>.filled(ABIConst.uintBytesLength, 0);
  List<int> addrBytes = input.toBytes();
  if (addrBytes.length == TronAddress.lengthInBytes) {
    addrBytes = addrBytes.sublist(TronAddress.lengthInBytes - addrLength);
  }
  bytes.setAll(ABIConst.uintBytesLength - addrLength, addrBytes);
  return EncoderResult(isDynamic: false, encoded: bytes);
}