Skip to content

Instantly share code, notes, and snippets.

@j2abro
Last active April 10, 2022 00:42
Show Gist options
  • Save j2abro/9e640b0026ec69646f90e6f49558c7dd to your computer and use it in GitHub Desktop.
Save j2abro/9e640b0026ec69646f90e6f49558c7dd to your computer and use it in GitHub Desktop.
import IUniswapV2Factory from "@uniswap/v2-core/build/IUniswapV2Factory.json" assert {type: "json"};
import { ethers } from 'ethers';
const provider = new ethers.providers.InfuraProvider("homestead", INFURA_KEY);
const UniswapV2FactoryAddress = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
(async () => {
const factory = new ethers.Contract( UniswapV2FactoryAddress , IUniswapV2Factory.abi , provider )
let numPairs = await factory.allPairsLength();
console.log('Number of Uniswap V2 Trading Pairs:', numPairs.toString());
}) ();
//Prints --> Number of Uniswap V2 Trading Pairs: 69636
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment