Created
June 28, 2018 11:03
-
-
Save murphyjohn/e01822a34eb608696270cc430fc650cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<title>Ethereum Account Explorer</title> | |
<script src="http://raw.githubusercontent.com/ethereum/web3.js/0.16.0/dist/web3.min.js"></script> | |
<script> | |
web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io")); | |
function printAccountBalance() { | |
var GET = {}; | |
var query = window.location.search.substring(1).split("&"); | |
for (var i=0, max = query.length; i<max; i++) | |
{ | |
if (query[i] === "") //check for trailing & with no param | |
continue; | |
var param = query[i].split("="); | |
GET[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || ""); | |
} | |
var account = GET.account; | |
var balanceWei = web3.eth.getBalance(account).toNumber(); | |
var balance = web3.fromWei(balanceWei, 'ether'); | |
document.write('[' + account + ']<br><br>') | |
document.write(balance + ' Ether'); | |
} | |
function test(){ | |
var wallet = web3.eth.accounts.create(); | |
var walletAddress = wallet.address; | |
var privateKey = wallet.privateKey; | |
document.write(''+ walletAddress); | |
document.write(''+privateKey) | |
} | |
</script> | |
</head> | |
<body> | |
<h2>John's Ethereum Account Explorer</h2> | |
<form method=GET action="EthereumExplorer.html"> | |
Enter an account: <input type=text size=50 name=account><input type="submit"> | |
</form> | |
<br> | |
<p>Latest Block: | |
<script> | |
document.write(web3.eth.blockNumber + "<br><br>"); | |
</script> | |
</p> | |
<p>Account Balance | |
<script> | |
printAccountBalance(); | |
</script> | |
</p> | |
<p> | |
Newly created Wallet: | |
<script> | |
test(); | |
</script> | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment