Skip to content

Instantly share code, notes, and snippets.

@alexander-elgin
Created October 17, 2018 11:52
Show Gist options
  • Save alexander-elgin/106890c9704888910c9ab4fe481ea30d to your computer and use it in GitHub Desktop.
Save alexander-elgin/106890c9704888910c9ab4fe481ea30d to your computer and use it in GitHub Desktop.
Get ETH Balance
const Web3 = require('web3');
const testnet = 'https://rinkeby.infura.io/';
const walletAddress = '0xcde7bd7943944dc558a427ef061400a4da9ee822';
void async function() {
try {
const web3 = new Web3(new Web3.providers.HttpProvider(testnet));
const balance = await web3.eth.getBalance(walletAddress);
console.log('the balance is', web3.utils.fromWei(balance, 'ether'))
} catch (error) {
console.error(error)
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment