Open Macket opened 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
Code:
Output: