Uncle Longmao
Be cool!
Ethereum is a decentralized platform that runs smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference.
Secure, reliable, and scalable access to Ethereum APIs
Test Ethereum Network (Rinkeby):https://rinkeby.infura.io/<your-token>
let web3;
// 浏览器环境且已经安装了 Metamask
if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
web3 = new Web3(window.web3.currentProvider);
// 服务器环境或者没有安装 Metamask
} else {
web3 = new Web3(new Web3.providers.HttpProvider(publicRuntimeConfig.infuraUrl));
}
......
const address = '' // Your account address goes here
web3.eth.getBalance(address, (err, wei) => {
balance = web3.utils.fromWei(wei, 'ether')
})
By Uncle Longmao