PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

Unable to call performUpkeep(), receiving error "cannot estimate gas" #112

Closed pooolz closed 1 year ago

pooolz commented 1 year ago

Would very much appreciate assistance here. I first attempted debugging the chainlink side but then went to try to execute perform upkeep through hh console and noticed that I am not able to execute it successfully.

Went through these steps:

hh deploy --network goerli

hh console --network goerli

const { ethers, deployments } = require('hardhat');
await deployments.fixture('all');

const deployer = (await ethers.getSigners())[0];

const Raffle = await ethers.getContract('Raffle', deployer);

await Raffle.enterRaffle({ value: ethers.utils.parseEther("0.01") })

// This line must return true
await Raffle.checkUpkeep([]);

// Then try to perform by yourself
await Raffle.performUpkeep([]);

checkUpkeep() at this point returns [ true, '0x', upkeepNeeded: true ]

executing performUpkeep() returns:

Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted", method="estimateGas", transaction={"from":"0x97A08B37AbD78275fD84A803fBfAF87fBe6c64AF","to":"0x0b2145adf128F63902ea6F84d29e41BE8154f569","data":"0x4585e33b00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000","accessList":null}, error={"name":"ProviderError","_stack":"ProviderError: HttpProviderError\n    at HttpProvider.request (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)\n    at LocalAccountsProvider.request (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/providers/accounts.ts:187:34)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at EthersProviderWrapper.send (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)","code":3,"_isProviderError":true,"data":"0xf0019fe600000000000000000000000000000000000000000000000000000000000017100000000000000000000000000b2145adf128f63902ea6f84d29e41be8154f569"}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.2)
    at step (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at EthersProviderWrapper.<anonymous> (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:642:20)
    at checkError (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:78:20)
    at Logger.throwError (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at Logger.makeError (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) {
  reason: 'execution reverted',
  code: 'UNPREDICTABLE_GAS_LIMIT',
  method: 'estimateGas',
  transaction: {
    from: '0x97A08B37AbD78275fD84A803fBfAF87fBe6c64AF',
    to: '0x0b2145adf128F63902ea6F84d29e41BE8154f569',
    data: '0x4585e33b00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000',
    accessList: null
  },
  error: ProviderError: HttpProviderError
      at HttpProvider.request (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
      at LocalAccountsProvider.request (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/providers/accounts.ts:187:34)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at EthersProviderWrapper.send (/Users/sam/Documents/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
}

I tried upping the gas limit in network config but it did not seem to do anything:

const networkConfig = {
    5: {
        name: "goerli",
        vrfCoordinatorV2: "0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D",
        entranceFee: ethers.utils.parseEther("0.01"),
        gasLane: "0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15",
        subscriptionId: "5904",
        callbackGasLimit: "1000000", // 500,000
        interval: "30",
    },

I am calling performUpkeep() with the deployer address. In case the issue was with the deployer address, I tried calling again from deployer address after changing performUpkeep to public instead of external and it didn't change the outcome Here's a link to my repo https://github.com/samwise00/hardhat-smartcontract-lottery-fcc

Thanks all

PatrickAlphaC commented 1 year ago

Can you:

  1. Make this a discusson on the full repo? https://github.com/smartcontractkit/full-blockchain-solidity-course-js/ Thanks!