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());
}
main();
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?