toTransactionParams method

Map<String, dynamic> toTransactionParams()

Implementation

Map<String, dynamic> toTransactionParams() {
  final calldata = encodeCalldata();
  final params = <String, dynamic>{
    'to': contract.address.toChecksumHex(),
    'data': '0x${_hexEncode(calldata)}',
  };
  if (from != null) params['from'] = from!.toChecksumHex();
  if (value != null) params['value'] = '0x${value!.toRadixString(16)}';
  if (gasLimit != null) params['gas'] = '0x${gasLimit!.toRadixString(16)}';
  if (nonce != null) params['nonce'] = '0x${nonce!.toRadixString(16)}';
  if (maxFeePerGas != null) {
    params['maxFeePerGas'] = '0x${maxFeePerGas!.toRadixString(16)}';
  }
  if (maxPriorityFeePerGas != null) {
    params['maxPriorityFeePerGas'] =
        '0x${maxPriorityFeePerGas!.toRadixString(16)}';
  }
  if (gasPrice != null) {
    params['gasPrice'] = '0x${gasPrice!.toRadixString(16)}';
  }
  return params;
}