ETHTransactionBuilder.contract constructor
ETHTransactionBuilder.contract({
- required ETHAddress from,
- required ETHAddress contractAddress,
- required BigInt value,
- required BigInt chainId,
- required AbiFunctionFragment function,
- required List functionParams,
- String? memo,
- ETHTransactionType? transactionType,
Factory constructor for creating a contract interaction transaction.
Implementation
factory ETHTransactionBuilder.contract(
{required ETHAddress from,
required ETHAddress contractAddress,
required BigInt value,
required BigInt chainId,
required AbiFunctionFragment function,
required List<dynamic> functionParams,
String? memo,
ETHTransactionType? transactionType}) {
final contractData = function.encode(functionParams);
final List<int> data = memo == null ? [] : StringUtils.toBytes(memo);
if (value > BigInt.zero) {
if (function.stateMutability != null &&
function.stateMutability != StateMutability.payable) {
throw const MessageException(
"For calling non-payable methods, the transaction value must be set to zero.");
}
}
return ETHTransactionBuilder._(
contractAddress,
from,
value,
[...contractData, ...data],
transactionType,
function,
functionParams,
chainId);
}