Local Blockchain Configuration

 let Web3 = require(‘web3’);

// console.log(‘first, ‘, Web3)
//connection with local blockchanin server
let Ganache = new Web3(new Web3.providers.HttpProvider(“HTTP://127.0.0.1:7545”));
// console.log(‘Ganache’, Ganache)
//frtch balance from a block
// let Balance = Ganache.eth.getBalance(“0x8E7ab97a7caBaFC57c2E528c3F55f670Dc4c8F09”).then(console.log);

let Balance = Ganache.eth.getBalance(“0x8E7ab97a7caBaFC57c2E528c3F55f670Dc4c8F09”).then((result)=>{console.log(Ganache.utils.fromWei(result,‘ether’))});
console.log(‘balance’ , Balance); //output is 100
//trnasfer some ether one account to lanother

let result = Ganache.eth.sendTransaction({from:“0x3D5169af2C5E753724d2590a02de07F882917808” , to :“0xa07960Ad5A710153D1D31f7C550DDBEaaaEb1718” , value:Ganache.utils.toWei(“0.008”, “ether”)});

console.log(‘result’,result );

Leave a Comment

Your email address will not be published. Required fields are marked *