y-pakorn / flutter_web3

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

[FIXED] When Call contractERC20.transferFrom() get Error: UNEXPECTED_ARGUMENT too many arguments #37

Closed faisalramdan17 closed 2 years ago

faisalramdan17 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

When Call contractERC20.transferFrom() get this one :

Error: EthersException: UNEXPECTED_ARGUMENT too many arguments: passed to contract

To Reproduce Steps to reproduce the behavior: I think I already put the true parameters like this one, but still get error :

TransactionResponse  resultTransferAllowance = await contractERC20!.transferFrom(
      transFromAddressCtrl.text,
      transToAddressCtrl.text,
      XConverter.amountToBigInt(transAmountCtrl.text, tokenContract!.decimals!),
    );

Getting My Own Solution

So, I try to check your package sourecode in Github : https://github.com/y-pakorn/flutter_web3/blob/main/lib/src/ethers/utils.dart

Then, I get your wrong code :

Screen Shot 2022-02-06 at 01 10 01

So meanwhile, currently waiting for your fixes then I have used this code :

final abi = [
      '''function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool)''',
    ];

    String address = tokenContract!.contractAddress;
    Contract contract = Contract(address, abi, provider!.getSigner());

    resultTransferAllowance = await contract.send(
      'transferFrom',
      [
        transFromAddressCtrl.text,
        transToAddressCtrl.text,
        XConverter.amountToBigInt(
            transAmountCtrl.text, tokenContract!.decimals!),
      ],
    );

Expected behavior

I think you only need little bit fixed like :

Replace : contract.send('transfer', [sender, recipient, amount.toString()]);

To be like this : contract.send('transferFrom', [sender, recipient, amount.toString()]);

It is simple, right. Thanks so much for your awesome packages. It's very Helpfully. Because I'm creating Dapp for welcoming Meetaverse Indonesia in my country.

y-pakorn commented 2 years ago

Fixed now. Thank you for your contribution ser!

faisalramdan17 commented 2 years ago

It's ok brother. anyway, is this package already support XRPL ? I want to try Dapp for XRPL. You can check this one : https://xrpl.org/docs.html

Thanks

y-pakorn commented 2 years ago

No, this package only supports Ethereum web3 through Ethers.js.