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.

interacting with deployed sc: contract.estimateGas.multisendEther throws cannot estimate gas;

See original GitHub issue

Hello everybody,

Could I ask someone to help me out figuring out why the following code throws an error when sending ether on rinkeby testnetwork to multiple addresses using multisender smart contract. Abi for the smart contract: https://gist.github.com/rstormsf/881a0c437245efed4729e31d3b9d8da8

Error: cannot estimate gas; transaction may fail or may require manual gas limit

The estimateGas error message might show up because of the reverted transaction. But I cannot seem to find a cause for the revert. Is it because of the value that is value: BigNumber { _hex: '0x00', _isBigNumber: true }? If yes, then how should I parse the value to be 1 ether and 2 ether and send it to my testnet wallets using multisend. I also want to do something which is if estimateGas > someEth then don’t execute with multisendEther. Is this something possible with ethers.js?

const amount = ethers.utils.parseEther('1.0');
const amount2 = ethers.utils.parseEther('2.0');

const transactionOptions = {
    gasLimit: 6000000,
    gasPrice: ethers.utils.parseUnits('1.0', 'gwei')

}
 //  contract_rw === connected to a Wallet with my private key. 
const multiSendEth = async ( ) => {
    const response =
        await contract_rw.estimateGas.multisendEther([targetAddress1,targetAddress2 ], [amount, amount2], transactionOptions)

    console.log(response)
}
contract_rw.ontransfer = function(from, to, amount) {
    const text = ethers.utils.formatEther(amount);
    console.log("Transfer");
    console.log("  From:   ", from);
    console.log("  To:     ", to);
    console.log("  Amount: ", text);
    // nonce: 17,
    //     gasPrice: BigNumber { _hex: '0x3b9aca00', _isBigNumber: true },
    // gasLimit: BigNumber { _hex: '0x5b8d80', _isBigNumber: true },
    // to: '0xA5025FABA6E70B84F74e9b1113e5F7F4E7f4859f',
    //     value: BigNumber { _hex: '0x00', _isBigNumber: true },
    // data: '0xab883d28000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d2a314cd8029802166551d0962dce420c5abcf400000000000000000000000037573745d9ae876904bd3369c8ba07f17896d84700000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000001bc16d674ec80000',
    //     chainId: 4,
    //     v: 43,
    //     r: '0xe88cb9bd3a13b8c2bc1c13e5a05a16674241ce804f2a214bae00c3b9d5732f61',
    //     s: '0x7b8d5e1ef0c5bb1903931f12f1f89823f8d7fe975e42238aaf1d9eaba53bd842',
    //     from: '0xc33C31Ff0b6C13c643b80d6C63C8A44e507dd273',
    //     hash: '0x5c9bfab71c00b7426d28901b2f1bce17a45e5f4a25f764e676f0751897f2e78c',
    //     wait: [Function]
}

Thank you for all the help! And long live the financial revolution. 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zemsecommented, Jan 17, 2021

The revert is likely because if insufficient msg.value sent to the multisender contract, which tries to send given eth to your target addresses.

const transactionOptions = {
    gasLimit: 6000000,
    gasPrice: ethers.utils.parseUnits('1.0', 'gwei')
    value: ethers.utils.parseEther('3.0') // adding this should fix
}
0reactions
ricmoocommented, Feb 1, 2021

Oh yes, you are correct, that is just how Etherscan shows contract interactions. It’s a weird way to describe it, but it’s at least something. 😃

I think this is answered then? I’m going to close it, but if not, please re-open.

Thanks! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: cannot estimate gas; transaction may fail or may require ...
But when I run the deploy script, keep showing Error: cannot estimate gas; transaction may fail or may require manual gas limit. I...
Read more >
transaction may fail or may require manual gas limit - Contracts
Cannot estimate gas ; transaction may fail or may require manual gas limit ... Here is my command to deploy the SC in...
Read more >
How do you estimate the amount of gas required for a smart ...
When invoking smart contract functions that have the pure or view modifiers, no gas (and therefore gas estimation) is necessary.
Read more >
Ethereum Gas Exactimation - Truffle Suite
In Ethereum, estimating gas for a given transaction is a tricky problem to solve (especially when attempting to maintain EIP-114 compliance).
Read more >
transaction may fail or may require manual gas limit" : r/ethdev
"Error: cannot estimate gas; transaction may fail or may require ... The tx throws an error, but before the tx it tries to...
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