Loading...
Hello Folks,
So in this session we will be discussing about How to create an Ethereum account 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://mainnet.infura.io/v3/your_api_key
var url = 'your RPC url here'
Then run this one
var web3 = new Web3(url)
and finally run this code
web3.eth.accounts.create()
This will create your ethereum account on the provided blockchain network.
Output will be somehow like this
{
address: '0x9c78052E6940177b0271fDd04A608B2D739Ec0fB',
privateKey: '0xfd9320c6cf8641d1d61b2c51a5a990dcd178bcxdc42ed15cc61d3a2d7954c678',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}
And boom your account is created!
And you should never ever share your private key
It was just for educational purpose.
For test ethers and link tokens. Click Here
For many more exciting tutorials keep following my username @BlockTalks_Raj
!!!!!HAPPY LEARNING!!!!