<script> var host = $("#host").val(); var address = $("#address").val(); varWeb3 = require('web3'); var web3 = newWeb3(); //default "http://localhost:8545" web3.setProvider(new web3.providers.HttpProvider(host)); var coinbase = web3.eth.coinbase; var originalBalance = web3.eth.getBalance(coinbase).toNumber(); console.log(coinbase); console.log(originalBalance); var version = web3.version.api; console.log(version); var version = web3.version.node; console.log(version); var mining = web3.eth.mining; console.log("节点是否挖矿:"+mining); // true or false var accounts = web3.eth.accounts; console.log(accounts); var number = web3.eth.blockNumber; console.log("当前区块号:"+number); var info = web3.eth.getBlock(number); console.log("区块"+number + "的信息:"); console.log(info); var balance = web3.eth.getBalance(address); $("#balance").html("余额:"+balance); console.log("余额:"+balance); // instanceof BigNumber console.log("余额stirng:"+balance.toString(10)); // '1000000000000' console.log("余额number:"+balance.toNumber()); // 1000000000000 </script> </body> </html>