y-pakorn / flutter_web3

Web3 Ethereum, Etherjs and Wallet Connect wrapper for Flutter Web.
Other
134 stars 47 forks source link

How to interact with a payable method in a contract? #12

Closed mlemos closed 2 years ago

mlemos commented 2 years ago

I'm trying to interact with a payable function/method in a contract. But I'm not sure on how to specify the value on the code and I'm getting this error:

Screen Shot 2021-09-25 at 12 51 57 PM

Basically I don't know how to define the value in a payable transaction with a contract.

My ABI is like this:

"function bet(uint256[] max) payable returns (bool)"

And I'm calling the like this:

if (contract == null) {
  contract = Contract(
    address,
    Interface(abi),
    provider!.getSigner(),
  );
}
final tx = await contract.send(
  'bet',
  [max],
);

Any help is welcome!

y-pakorn commented 2 years ago

Define override property in send method to be not null.

Example.

final tx = await contract.send(
  'somePaybleFunction',
  [],
  TransactionOverride(value: BigInt.from(1)),
);