Cannot estimate gas error calling a function

I am getting "cannot estimate gas error" when it try to call some function..can anyone help me to solve this issue..here is my full error log..

Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"message":"execution reverted","code":-32000}, method="estimateGas", transaction={"from":"0xEB50a80F7DE37AF8669b0C4973B2A33E8502c5a7","to":"0xc11ac4b9Cd101a25496fE8F2d12d0EDB6ACeD7d5","data":"0xaf14052c"}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.0.14)
at step (D:\one\node_modules@ethersproject\providers\lib\json-rpc-provider.js:46:23)
at EthersProviderWrapper. (D:\one\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:455:20)
at checkError (D:\one\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:59:16)
at Logger.throwError (D:\one\node_modules@ethersproject\logger\src.ts\index.ts:217:20)
at Logger.makeError (D:\one\node_modules@ethersproject\logger\src.ts\index.ts:205:28) {
reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
code: 'UNPREDICTABLE_GAS_LIMIT',
error: Error: execution reverted
at HttpProvider.send (D:\one\node_modules@nomiclabs\buidler\src\internal\core\providers\http.ts:36:34)
at D:\one\node_modules@nomiclabs\buidler\src\internal\core\providers\accounts.ts:149:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at EthersProviderWrapper.send (D:\one\node_modules@nomiclabs\buidler-ethers\src\ethers-provider-wrapper.ts:13:20) {
code: -32000,
data: undefined
},
method: 'estimateGas',
transaction: {
from: '0xEB50a80F7DE37AF8669b0C4973B2A33E8502c5a7',
to: '0xc11ac4b9Cd101a25496fE8F2d12d0EDB6ACeD7d5',
data: '0xaf14052c'
}
}

2 Likes

I think you have deployed the contract on the Rinkeby network, and you have verified the proxy contract, but where is the implementation contract and which function are you trying to call?

1 Like

Hi @Prabhakaran,

Can you verify the implementation contract:

I suggest using the following: Verify smart contract inheriting from OpenZeppelin Contracts

yes @skyge I deployed the contract on rinkeby network and and i tried to check it through console itself by running commands like ..
$ npx hardhat console --network rinkeby

const Box = await ethers.getContractFactory("Box")
undefined
const box = await Box.attach("0xFF60fd044dDed0E40B813DC7CE11Bed2CCEa501F")
undefined
(await box.retrieve()).toString()
'42'
like this I tried to call my function..
and i will verify it on etherscan and send contract address shortly..

1 Like

Hi @abcoathup,
I didn’t verify it on etherscan i just tried to run it on console …as i mentioned on previous reply…
I will verify it and send contract address …shortly as possible.

1 Like

The error is pretty common in proxy pattern based SC.

The error looks like this:

reason: 'cannot estimate gas; transaction may fail or may require manual gas limit' code: 'UNPREDICTABLE_GAS_LIMIT',
  • Cause: There is some kind of ERC20 token being transferred to the contract using a function e.g. allocatePC for SC: crowdfunding-sc. So, the caller doesn't have enough ERC20 token. Hence, it is throwing error. This happens in proxy based architecture including architecture like diamond standard, openzeppelin proxy pattern.

  • Solution: Mint PC to deployer & then interact with the contract's function - allocatePC

NOTE: allocatePC function accepts ERC20 token & then set some activity based on requirement.