Loading...
Hello Folks,
So in this session we will be discussing about checking an account address to be correct or not using web3 from nodejs.
To do that we need to have web3 Node module installed on our system.
We can do this by running the following code on the cmd
npm install web3
Then let's run our node server. Just run the following code on cmd.
node
Then we need web3 module in our server so run the following code
var Web3 = require('web3')
we will be needing a Blockchain network to create an account so get an rpc url from here
Just click on the link -> Login to your account ->Click on ethereum on left side bar ->create project ->settings->keys->endpoints
and choose your respective testnet rpc url
rpc url it will look like this - https://kovan.infura.io/v3/your_api_key
var url = 'your RPC url here'
Then run this one
var web3 = new Web3(url)
To check whether the account address is correct or not we can use the following utility function
web3.utils.isAddress('your address here')
This will return a boolean value ture or false as per the input provided.It will also check the checksum if the address has upper and lowercase letters.
It is essential to validate whether the ethereum address exists or not before proceeding for any transaction.
For test ethers and link tokens. Click Here
For many more exciting tutorials keep following my username @BlockTalks_Raj
!!!!!HAPPY LEARNING!!!!