Created
October 17, 2018 11:52
-
-
Save alexander-elgin/106890c9704888910c9ab4fe481ea30d to your computer and use it in GitHub Desktop.
Get ETH Balance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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