Interacting with Ethereum via web3
FIGURE 5.3 A demo page for web3.js
web3 = new Web3(new Web3.providers.HttpProvider( "https://mainnet.infura.io/"));
var balanceWei = web3.eth.getBalance(acct).toNumber(); var balance = web3.fromWei(balanceWei, 'ether');
Our demo application queries the account balance. The balance is public information and does not require any account private key. If your web3.js application needs to send ETH from one account to another, you will need access to the sending account’s private key. There are several ways to do this, and I will cover them in Chapter 8.