loom-js icon indicating copy to clipboard operation
loom-js copied to clipboard

Cannot execute ethers.js contract method without specifying optional transaction overrides argument

Open rjkz808 opened this issue 5 years ago • 8 comments

Description

When I try to run EthereumGatewayV2.withdrawAsync method without providing overrides argument (which is marked as optional in loom-js code) it throws this error:

Error: incorrect number of arguments
    at Object.withdrawETH (node_modules/loom-js/node_modules/ethers/contract.js:130:19)
    at EthereumGatewayV2.<anonymous> (node_modules/loom-js/dist/ethereum-gateways.js:78:66)
    at step (node_modules/tslib/tslib.js:136:27)
    at Object.next (node_modules/tslib/tslib.js:117:57)
    at fulfilled (node_modules/tslib/tslib.js:107:62)
    at process._tickCallback (internal/process/next_tick.js:68:7)

When I pass an overrides object with a gasLimit property specified, everything works fine. At least, this argument have to be marked as required in withdrawAsync function signature.

Versions

  • ethers: 4.0.38
  • loom-js: 1.70.0

rjkz808 avatar Oct 23 '19 18:10 rjkz808

I also want to note that this issue can also appear in other loom-js parts which use ethers.Contract object to interact with a smart contract. So, I hope that you will test some other code where ethers.Contract is being used

rjkz808 avatar Oct 23 '19 18:10 rjkz808

Which network is it? Ext-dev or plasma?

redben avatar Oct 23 '19 18:10 redben

@redben We use it with extdev and rinkeby

rjkz808 avatar Oct 23 '19 22:10 rjkz808

Please provide a snippet of code that can be used to reproduce this error.

enlight avatar Oct 24 '19 04:10 enlight

Please provide a snippet of code that can be used to reproduce this error.

You can just call EthereumGatewayV2 instance withdrawAsync method without passing an overrides object. I think you can fork truffle-dappchain-example repo, remove { gasLimit: gas } object from this line and run the corresponding CLI subcommand to trigger this function

rjkz808 avatar Oct 24 '19 10:10 rjkz808

@enlight Same issue reported by Sorare. They're using ethers 4.0.37 and they tried to call the withdrawAsync function with a single argument like:

withdrawAsync(receipt)

This resulted in the following error:

incorrect number of arguments

I asked them to pass the gasLimit as the second argument:

await gatewayContract.withdrawAsync(receipt, { gasLimit: gas })

and this worked.

I don't know if there's an issue with loom-js or ethers though.

andreipope avatar Dec 06 '19 13:12 andreipope

@andreipope maybe it's because loom-js doesn't set default gas limit for basechain and ethers just requires developers to explicitly specify it? With ethereum network there's no such issue.

rjkz808 avatar Dec 07 '19 22:12 rjkz808

I also can mention that when using our own contracts with ethers.js and loom-js we also need to provide the gas limit. So, in my opinion it's because LoomProvider instances doesn't have the default gas limit at all and it's quite logical that ethers.js forces developers to provide some gas value to send transactions with.

rjkz808 avatar Dec 07 '19 23:12 rjkz808