I am trying to run the test on mainnet fork using hardhat-deploy example template, particularly the for-test branch example.


After providing the .env variables. I ran yarn fork:test mainnet

But I kept getting stuck at this particular error on the aToken_Dai test. I thought maybe the ABI was outdated and tried updating it from the mainnet contract but still doesn't work. Test kept getting reverted when running evm_increaseTime. Am I missing anything that needs to pass the test?


    await network.provider.request({
      method: 'evm_increaseTime',
      params: [3600 * 24 * 365],

$ node ./_scripts.js fork:test mainnet

Nothing to compile
No need to generate any newer typings.
    ✔ setMessage works (7855ms)

    ✔ transfer fails
    ✔ transfer succeed

    1) aToken_Dai works

  3 passing (43s)
  1 failing

  1) aToken_Dai
       aToken_Dai works:
     Error: VM Exception while processing transaction: revert SafeERC20: low-level call failed
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at HardhatNode._mineBlockWithPendingTxs (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1154:23)
    at HardhatNode.mineBlock (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:377:16)
    at EthModule._sendTransactionAndReturnHash (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1377:18)
    at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:101:18)
    at EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)


1 Answer 1


The .env.example provided by the project seems to be missing a few environment variables that are being used in hardhat.config.ts.

In your .env, make sure to set HARDHAT_FORK to mainnet. Also, make sure to set HARDHAT_FORK_NUMBER to a block number where all dependent contracts already exist on mainnet.

  • I didn't know I had to set those since they weren't in the .env.example. All tests pass after I set those in the .env file! Thank you!
    – cgeyser
    Jul 31, 2021 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.