I want to call Quoter Contract on BSC Mainnet which is deployed already.

I'm using HardHat or Foundry to fork Mainnet specific blocknumber, here is HardHat Config JS:

module.exports = {
  solidity: "0.8.19",
  networks: {
    hardhat: {
      forking: {
        // url: Also Try Using QuickNode API,
        url: "",// Local Server is running Geth Service on 8540 port
        blockNumber: 31723542,//Trying to fork this blockNumber
        chainId: 56

Or Using Foundry Anvil:

anvil --fork-url QuickNode's_HTTP_EndPoint --fork-block-number 31723542 --chain-id 56

My Test JS File

const { Web3 } = require('web3');
const {ethers } = require('ethers')
//Quoter Address ABI JSON
jsonFile = "./bsc-quoter.json";
parsed = JSON.parse(fs.readFileSync(jsonFile));
var bscAbi = parsed
bscQuoterAddress = '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997'

const rpcURL = ""//Using Local HardHat or Foundry Fork
var web3 = new Web3(new Web3.providers.HttpProvider(rpcURL));
const provider = new ethers.providers.JsonRpcProvider(rpcURL)

const bscQuoter = new ethers.Contract(

const main = async() => {
//Just Random Pick a V3Pool Address
    const params = {


    const amountOut = await bscQuoter.callStatic.quoteExactInputSingle(


This is BSC Mainnet Quoter Contract Address (Which is already deployed in previous block)


Then, I Just Call the js:

npx hardhat run ./quoter.js
npx hardhat run ./quoter.js --network localhost

It failed.

HardHat Fork Terminal log:

  WARNING: Calling an account which is not a contract
  From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:   0xb048bbc1ee6b733fffcfb9e9cef7375518e25997

This Quoter is a Contract , I don't know why it failed.

But when forking without blocknumber, it success.

  • Your issue seems similar to this: ethereum.stackexchange.com/q/154528/86303
    – MShakeG
    Commented Sep 18, 2023 at 7:05
  • @MShakeG emm, Yep seems similar, don't notice before. Maybe the same problem. I'm noob with DAPP dev, can't find any tech article to teach about this situation.
    – Sylar
    Commented Sep 18, 2023 at 8:58

1 Answer 1


To do a proper fork with Hardhat (or Foundry, or Truffle etc), you need to be forking a node that is archive. If you are forking a full node, you will have the state pruned. You normally also get a "missing trie" error from the full node on an attempt to fork, not sure why you are not getting that.

My suggestion is double-check that you are forking off an RPC endpoint of an archive node.

As an example, I just forked the chain with your settings (same block) but using a BSC mainnet archive node from Chainstack and then ran the following sample code (same contract) and it works. (I think your test.js needs some cleaning up, like web3 doesn't seem to be used etc).

Simple test code against the forked chain:

const { ethers } = require('ethers');

const contractAbi = ABI_OFF_ETHERSCAN

const contractAddress = '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997';

const rpcURL = "";
const provider = new ethers.JsonRpcProvider(rpcURL);

const main = async () => {
    const contract = new ethers.Contract(contractAddress, contractAbi, provider);
    try {
        // Fetch the WETH9 address
        const weth9Address = await contract.WETH9();
        console.log("WETH9 Address:", weth9Address);

        // Fetch the deployer address
        const deployerAddress = await contract.deployer();
        console.log("Deployer Address:", deployerAddress);

        // Fetch the factory address
        const factoryAddress = await contract.factory();
        console.log("Factory Address:", factoryAddress);
    } catch (error) {
        console.error("An error occurred:", error.message);


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.