question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andreipopecommented, Dec 6, 2019

@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.

0reactions
rjkz808commented, Dec 7, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending an argument with an ethers contract object
I need to pass an argument userTeamChosen with a appendUserBet() function which I both set the values for through html forms but get...
Read more >
Contract with function overloading · Issue #407 · ethers-io ...
I'm getting the error: Error: incorrect number of arguments when I'm trying call the second function. Seems that when Contract is reading ...
Read more >
Documentation - Ethers.js
A second optional parameter allows API keys to be specified to each Provider created ... Returns the result of executing the transaction, using...
Read more >
Contracts — ethers.js 4.0.0 documentation
Every Contract method may take one additional (optional) parameter which specifies the transaction (or call) overrides. Contract Transaction Overrides¶. // All ...
Read more >
Set gas limit on contract method in ethers.js - Stack Overflow
You can set the gas limit with an object as the last argument, for a simple transfer transaction, you could do something like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found