Skip to content

Instantly share code, notes, and snippets.

@devonwesley
Last active December 20, 2017 02:22
Show Gist options
  • Save devonwesley/2c257819c318d0cb083368ba671f11b1 to your computer and use it in GitHub Desktop.
Save devonwesley/2c257819c318d0cb083368ba671f11b1 to your computer and use it in GitHub Desktop.
This snippet of code is for the blog series that i am writing.
function getAccounts() {
const ethAccount = web3.eth.accounts[0]
return document
.getElementById('account-addresses')
.innerHTML = `<div>
Account: ${ethAccount}
<br />
Balance: ${balanceInEth(ethAccount)}
</div>
`
}
function balanceInEth(address) {
return web3.fromWei(web3.eth.getBalance(address).toString(), 'ether')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment