encode method

  1. @override
Uint8List encode(
  1. dynamic obj
)
override

Encode values with ABI rules based on the ABI type schemes @return byte[] of ABI encoding @throws IllegalArgumentException if encoder cannot infer the type from obj

Implementation

@override
Uint8List encode(dynamic obj) {
  if (obj is BigInt) {
    return BigIntEncoder.encodeUintToBytes(obj, bitSize ~/ 8);
  }

  if (obj is num) {
    return BigIntEncoder.encodeUintToBytes(BigInt.from(obj), bitSize ~/ 8);
  }

  if (obj is String) {
    return BigIntEncoder.encodeUintToBytes(BigInt.parse(obj), bitSize ~/ 8);
  }

  throw ArgumentError('Cannot infer type for uint value encode');
}