2018-08-23 19:46:27 -07:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Create a new account</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<b>Account</b>
|
|
|
|
<div id="accountPublicKey">?</div>
|
|
|
|
has a balance of
|
|
|
|
<div id="accountBalance">?</div>
|
|
|
|
|
|
|
|
<script src="../lib/index.iife.js"></script>
|
|
|
|
<!--
|
|
|
|
<script src="https://github.com/solana-labs/solana-web3.js/releases/download/v0.0.4/solanaWeb3.min.js"></script>
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script>
|
|
|
|
// Create a new account
|
|
|
|
const account = new solanaWeb3.Account();
|
|
|
|
|
|
|
|
// Display the account's public key
|
|
|
|
const accountPublicKey = document.getElementById('accountPublicKey');
|
|
|
|
accountPublicKey.innerHTML = account.publicKey;
|
|
|
|
|
|
|
|
// Fetch account balance
|
|
|
|
let url;
|
|
|
|
url = 'http://localhost:8899';
|
2018-09-12 17:11:05 -07:00
|
|
|
//url = 'http://testnet.solana.com:8899';
|
2018-08-23 19:46:27 -07:00
|
|
|
const connection = new solanaWeb3.Connection(url);
|
|
|
|
|
|
|
|
connection.getBalance(account.publicKey)
|
|
|
|
.then((balance) => {
|
|
|
|
const accountBalance = document.getElementById('accountBalance');
|
|
|
|
accountBalance.innerHTML = balance;
|
|
|
|
console.log(`${account.publicKey} has a balance of ${balance}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|