Part 3 of Intro to Web3

OK ya’ll…I was a bit silly…it’s been a while since I did node.js…or JavaScript in general…lol

So, you if you’re wanting to get the balance of an Ethereum address, you need to:

> const Web3 = require('web3')

> const rpcURL = '‘ // Your RPC URL

> const web3 = new Web3(rpcURL)

> const address = '‘ // The address you want to get the balance of

> web3.eth.getBalance(address, (err, wei) => {

> balance = web3.utils.fromWei(wei, 'ether')

> })

And the value of balance for the address in Gregory’s tutorial was 0. BUT, when I did this with my own address then I did the piece I missed facepalm

> balance

'0.022268519462640474'

This still doesn’t explain the second example though, because it was a print to the console’s log…Let’s watch the next video.

Hmm, it would seem I had done everything correct for the second example, I just am not getting a response. I might have to explore some other tutorials and resources tomorrow.

Next
Next

Continuing Intro to Web3