Skip to content

Instantly share code, notes, and snippets.

@yurenju
Created October 27, 2019 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurenju/dc4040d79b45b16d167dd659ed701ea1 to your computer and use it in GitHub Desktop.
Save yurenju/dc4040d79b45b16d167dd659ed701ea1 to your computer and use it in GitHub Desktop.
const ethers = require("ethers");
(async function() {
const address = "0x477b8D5eF7C2C42DB84deB555419cd817c336b6F";
const provider = ethers.getDefaultProvider();
const block1 = 8821739;
const block2 = 8821081;
let balance1 = ethers.utils.formatEther(await provider.getBalance(address, block1));
let balance2 = ethers.utils.formatEther(await provider.getBalance(address, block2));
console.log(`balance for block ${block1}: ${balance1}`);
console.log(`balance for block ${block2}: ${balance2}`);
})();
// balance for block 8821739: 1600.687191129372744769
// balance for block 8821081: 1571.814645737610244769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment