Loading...
Hello Folks,
So in this session we will be discussing about Ethereum transactions 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
We also need to have ethereumjs package installed on our computer by running this code
npm install ethereumjs-tx
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)
Then you copy two account addresses from kovan testnet having some test ethers in it
const account1 = 'Your 1st account address here'
const account2 = 'Your 2nd account address here'
To send 1 ether from account 1 to account 2 we can use this code
web3.eth.sendTransaction({from: account1, to: account2, value: web3.utils.toWei('1','ether')})
And boom!
you have successfully transfered 1 ether from one account to other.
For test ethers and link tokens. Click Here
For many more exciting tutorials keep following my username @BlockTalks_Raj
!!!!!HAPPY LEARNING!!!!