Show usage of web3
adrianmcli opened this issue · 1 comments
adrianmcli commented
The dapp page currently does not demonstrate use of web3
. Perhaps we can add a getEthBalance()
method in the component class to get the amount of ETH stored in the first account. It might look something like this:
getEthBalance = async () => {
const { web3, accounts } = this.props
const balanceInWei = await web3.eth.getBalance(accounts[0])
this.setState({ ethBalance: balanceInWei / 1e18 })
}
Of course, we must remember to pass in web3:
<Web3Container
renderLoading={() => <div>Loading Dapp Page...</div>}
render={({ accounts, contract, web3 }) => (
<Dapp accounts={accounts} contract={contract} web3={web3} />
)}
/>
lightswarm124 commented
Sent a PR