const Web3=require("web3")
const web3=new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
console.log(web3.utils.fromWei("12345678901234567890","ether"))
console.log(web3.utils.fromWei("12345678901234567890","Gwei"))
console.log(web3.utils.fromWei("12345678901234567890","Mwei"))
console.log(web3.utils.toWei("1","ether"))
console.log(web3.utils.toWei("1","Gwei"))
console.log(web3.utils.toWei("1","Mwei"))
let h1=web3.utils.sha3("asfdghjf")
console.log(h1)
let h2=web3.utils.sha3(h1,{encoding:"hex"})
console.log(h2)
console.log(web3.utils.fromAscii("xyz"))
console.log(web3.utils.toAscii("0x78797a"))
console.log(web3.utils.toHex("a"))
console.log(web3.utils.toHex(1234))
console.log(web3.utils.toHex({name:"Alice"}))
console.log(web3.utils.toHex('{"name":"Alice"}'))
console.log(web3.utils.toHex(JSON.stringify({name:"Alice"})))
console.log(web3.utils.toHex([1,2,3]))
console.log(web3.utils.toHex('[1,2,3]'))
console.log(web3.utils.isAddress("0x7b226e616d65223a22416c696365227d"))
console.log(web3.utils.isAddress("0x63c682644eb04814735F2d592A9304385F263B76"))
console.log(web3.utils.toBN(1234))
console.log(web3.utils.toDecimal(1234))
const f=async () => {
let accounts=await web3.eth.getAccounts()
console.log(accounts)
let b1=await web3.eth.getBalance(accounts[1])
console.log(b1)
let b2=await web3.eth.getBalance(accounts[2])
console.log(b2)
await web3.eth.sendTransaction({
from:accounts[1],
to:accounts[2],
value:web3.utils.toWei("1","ether"),
gas:1000000
})
b1=await web3.eth.getBalance(accounts[1])
console.log(b1)
b2=await web3.eth.getBalance(accounts[2])
console.log(b2)
console.log(web3.eth.defaultAccount)
web3.eth.defaultAccount=accounts[0]
console.log(web3.eth.defaultAccount)
console.log(web3.eth.defaultBlock)
let b=await web3.eth.getBlock(0)
console.log(b)
let r=await web3.eth.estimateGas({
to:accounts[0]
})
console.log(r)
let coinbase=await web3.eth.getCoinbase()
console.log(coinbase)
}
f()