使用web3纯前端实现以太坊查账户余额

1.下包:

npm install node.js
npm install web3

2.调库,打印账户余额

var Web3=require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("测试网节点url"));
web3.eth.getBalance("查询账户地址").then(tx=>{
    console.log(tx)
})

web3 getBalance文档:
https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html?highlight=getBalance#getbalance

你可能感兴趣的:(区块链,web3,区块链,以太坊)