Loading...
Hello Folks,
So in this session we will be discussing about checksum addresses and to convert any ethereum address to checksum address 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)
Basic Syntax for left padding:
web3.utils.padLeft(string, characterAmount [, sign])
or
web3.utils.leftPad(string, characterAmount [, sign])
Here the string denotes the string to add padding on the left.
Here the characterAmount denotes the number of characters the total string should have at the end in Hex.
Here the sign is optional that denotes the string to be padded at the left; if not provided it sets default value as 0.
web3.utils.padLeft('0x3456ff', 20);
> "0x000000000000003456ff" //output
web3.utils.leftPad(0x3456ff, 20);
> "0x000000000000003456ff" //output
web3.utils.padLeft('Hello', 20, 'x');
> "xxxxxxxxxxxxxxxHello" //output
Similar for right padding
web3.utils.padRight('0x3456ff', 20);
> "0x3456ff00000000000000" //output
web3.utils.padRight(0x3456ff, 20);
> "0x3456ff00000000000000" //output
web3.utils.padRight('Hello', 20, 'x');
> "Helloxxxxxxxxxxxxxxx" //output
So that's all for today's session.
For test ethers and link tokens. Click Here
For many more exciting tutorials keep following my username @BlockTalks_Raj
!!!!!HAPPY LEARNING!!!!