Loading...
If we want to get balance of any account then first you need is the connection with ethereum blockchain. You can connect to ethereum blockchain using two ways .
1. You can use metamask for your connection ethereum node. first you need to install metamask extension which will acts like a provider to connect ethereum bloakchain .
to download metamask simply clik on following link Install metamask and follow metamask documentation.
after that you need to write following two lines of code to connect to blockchain
const Web3 = require('web3')
const web3 = new Web3(web3.currentProvider)
Now your web3 object has a connection with ethereum blockchain.you can connect to smart contract by adding contract ABI and contract ADDRESS.
2. Another way is to use infura url. Infura is a service that provides a remote ethereum node for freel. All you need to do is sign up and obtain an API key and the RPC URL for the network you want to connect to.
After you signed up your infura url look like this
https://mainnet.infura.io/YOUR_INFURA_API_KEY
now you need to write follwing code to connect to ethereum node
const Web3 = require('web3')
const rpcURL = '' // Your RPC URL goes here
const web3 = new Web3(rpcURL)
that much simple now you have connection with ethereum blockchain.