interacting with deployed sc: contract.estimateGas.multisendEther throws cannot estimate gas;
See original GitHub issueHello 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:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
The revert is likely because if insufficient
msg.value
sent to the multisender contract, which tries to send given eth to your target addresses.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! 😃