0

I am trying to get the balanace of an address, the address I am trying to get is the pair address when liquidity is added.

I have tried using provider.getbalance shown in this answer.

This is my code

factory.on('PairCreated', async (token0, token1, pairAddress) => {
  const balance = await provider.getBalance(pairAddress);
  console.log(`
    ${token0}
    ${token1}
    ${pairAddress}
    ${balance}
  `);

This returns

0x56Ca8Df9F4A602e449265931ff2dA8210F53F230
0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
0x148818634356E6af1d4727A26b8181D7b892aA8c
0

When I check the balance of 0x148818634356E6af1d4727A26b8181D7b892aA8c on bsc scan I get 3 different tokens with different balances, but when I try through ethers it returns 0.

How could I get the tokens/balances of pairAddress (0x148818634356E6af1d4727A26b8181D7b892aA8c) using ethers.js?

Thanks for any help

Jay Williams
  • 159
  • 1
  • 1
  • 8

0 Answers0