In building an IONIC app, I am attempting to retrieve the historical balance of a single Ethereum address. I am currently not sure how far back I will need to go. I know that Etherscan.IO offers a web tool to get balance from a certain date at https://etherscan.io/balancecheck-tool , however I cant find any API's that allow me to do this programmatically. I am also unable to get web3 to install in my current project. Any advise would be appreciated.


If you observe the balance check tool, you can see there are two options

  1. Date
  2. Block Number

If you know the block number, you can use the following function to get the historic balance

web3.eth.getBalance(address, blockNumber).then(balance => `Balance at block number is ${balance}

If you dont know the block number, but want to get it by date/time. You first need to find the block that is mined during that time.

let blockNum = web3.eth.blockNumber;
const historicTimestamp = new Date(historicDate).getTime();
while(true) {
  const block = web3.eth.getBlock(blockNum);
  if(block.timestamp < historicTimestamp) break;

//The blockNumber here is your required block number
web3.eth.getBalance(address, blockNumber).then(balance => `Balance at block number is ${balance}`);
  • I really appreciate the assistance on this. However, as I stated, I am unable to get web3 for use in my project, do you know of another way other than web3? – Kontra Feb 20 '18 at 20:40
  • Can you be more specific on what is not working with web3? – Sumanth Feb 21 '18 at 14:59
  • There was an issue with the package itself. I was able to get it to install. Thanks! – Kontra Feb 21 '18 at 17:17

You can use the defaultBlock parameter to get the historic balance. For example, using web3.js v1.0:

web3.eth.getBalance(account, 10000).then(balance => {console.log(`balance for ${account} at block 10000 is ${balance}`)});

Regarding the fact that you can't install web3 in your project, you should create another question, giving more details with what you tried and the errors you encounter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.