constructCallData function

String constructCallData(
  1. String recipient,
  2. BigInt sendValue
)

Implementation

String constructCallData(String recipient, BigInt sendValue) {
  // Keccak256 hash of `transfer(address,uint256)`'s signature
  final transferMethodId = 'a9059cbb';
  // Remove '0x' and pad
  final paddedReceiver = recipient.replaceFirst('0x', '').padLeft(64, '0');
  // Amount in hex, padded
  final paddedAmount = sendValue.toRadixString(16).padLeft(64, '0');
  //
  return '0x$transferMethodId$paddedReceiver$paddedAmount';
}