cavanmflynn / ethers-multicall

Make multiple Ethereum network requests in a single HTTP query. ethcall for ethers v5.
MIT License
224 stars 99 forks source link

Wrong eth balance for the first account generated by Ganache #11

Open Macket opened 3 years ago

Macket commented 3 years ago

Code:

import { Provider } from 'ethers-multicall';
import { ethers } from 'ethers';

(async function() {
    const provider = new ethers.providers.JsonRpcProvider('http://localhost:8545/');
    const ethcallProvider = new Provider(provider);
    await ethcallProvider.init();

    const ganche_account_0 = '0x66aB6D9362d4F35596279692F0251Db635165871';
    const ethBalance = await provider.getBalance(ganche_account_0);
    const [ethBalanceMulticall] = await ethcallProvider.all([ethcallProvider.getEthBalance(ganche_account_0)]);

    console.log('ETH Balance:', ethers.utils.formatUnits(ethBalance));
    console.log('ETH Balance multicall:', ethers.utils.formatUnits(ethBalanceMulticall));
})()

Output:

ETH Balance: 100.0
ETH Balance multicall: 180143885.09481982