I am trying to connect to the Pangolin DEX (a Uniswap fork) on the Avalanche Fuji testnet (Avalance uses EVM). With this:

import console from "console";
const ethers = require("ethers");

async function main(){

    // url is to a free shared Avalanche node on the Fuji testnet from Chainstack. It does work.
    var urlInfo = {url: 'https://nd-211-849-225.p2pify.com/nope/ext/bc/C/rpc'};
    const provider = new ethers.providers.StaticJsonRpcProvider(urlInfo, 43113);
    const block = await provider.getBlockNumber();
    console.log("Block Number is " + block); // block does have a value

    const PangolinFactory = "0xefa94DE7a4656D787667C749f7E1223D71E9FD88";
    const pangolinFactoryABI = [
        "function getPair(address tokenA, address tokenB) external view returns (address pair)",
        "function allPairs(uint) external view returns (address pair)",
        "function allPairsLength() external view returns (uint)"
    const contract = new ethers.Contract(PangolinFactory, pangolinFactoryABI, provider);
    console.log(await contract.allPairsLength());


The provider is connecting as it should, but the call to allPairsLength (or any method I try) always results in a CALL_EXCEPTION.

What am I missing?

1 Answer 1


You are trying to call a non-existent contract on the Fuji testnet, while the contract you specify is on the mainnet. You need to swap your Chainstack RPC endpoint from the Fuji one to the mainnet one.

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.