I have my hardhat network configured as a fork of Binance Smart Chain like this:

const config: HardhatUserConfig = {
  solidity: {
    version: "0.8.0",
    settings: {
      optimizer: {
        enabled: true,
        runs: 500,
  networks: {
    hardhat: {
      chainId: chainIds.bscMainnet,
      forking: {
        url: "https://bsc-dataseed.binance.org/",
        blockNumber: 31717026


The fork is working great and all the tests are passing with success. Now, I'm trying to integrate the Smart Contract on the forked Hardhat network, with Ethers.js, connecting to it trough Metamask (RPC URL: localhost:8545).

I can execute all the functions that generate a transaction (send) with no problems (same code of automated tests) but when I try to call view functions, or public state variables, I always getting the following error:

ethers-5.2.umd.min.js:1 Uncaught (in promise) Error: call revert
exception (method="registry()", errorArgs=null, errorName=null,
errorSignature=null, reason=null, code=CALL_EXCEPTION,


  • I have updated Hardhat to latest version (2.17.3) and the error keeps the same.
  • I can interact with contracts deployed in mainnet, accessing to view functions and state variables.

The problem only happens, trying to access view functions and state variables, from contracts deployed by myself in the locally forked BSC hardhat network. The error I see in the terminal, when I run the locally forked Blockchain is the following:

  WARNING: Calling an account which is not a contract
  From:            0x...
  To:              0x...


My code (plain javascript in html for testing purposes):

const provider = new ethers.providers.Web3Provider(window.ethereum);

await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();

let abi_registry = await fetch("./abis/Registry.json");
abi_registry = await abi_registry.json();
abi_registry = abi_registry.abi;
const registryAddr = "0xf07eC5fa63F57Ef97D5155FeC1D09cDF14a78BaC";
const registryContract = new ethers.Contract(registryAddr, abi_registry, provider);

async function platformFeeRate(){
  let numVaults = await registryContract.numVaults();

The error does not happen if I connect to contracts that are already deployed on a public network.


I have also tried avoiding hardhat.config.ts fork config, and starting a new fork node in the terminal, but I'm getting same result:

npx hardhat node --fork https://bsc.quiknode.pro/ --fork-block-number 31827701
  • what version of hardhat are you using? if you're on an older version you may want to upgrade to the latest(it's possible that this is a bug that has been fixed), also when was the contract you're trying to read deployed, was it before the configured block i.e. 31717026?
    – MShakeG
    Sep 16, 2023 at 19:50
  • I have upgraded to latest hardhat version and the error keeps the same. See my update above for more details (here takes too long). Sep 17, 2023 at 10:03
  • Can you provide the BSC mainnet contracts that you're trying to interact with via the hardhat local fork?
    – MShakeG
    Sep 17, 2023 at 10:15
  • The contracts I'm trying to interact with are contracts developed by me, not deployed in mainnet yet. If I interact with contracts deployed in mainnet, there is no problem. Sep 17, 2023 at 10:20
  • I understand, but can you provide the problem contracts deployed on mainnet that you're trying to interact with?
    – MShakeG
    Sep 17, 2023 at 11:09


Your Answer

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