libra-auth
Version:
An authentication method using Libra's Public Key and Secret Key.
50 lines (43 loc) • 1.65 kB
HTML
<html>
<head>
<meta charset=utf-8>
<title>test balance</title>
<script src=./js/libraweb-v2.js></script>
<style>
#res{
borger: 1px solid #ddd;
background: #eee;
padding:48px;
margin: 48px;
}
</style>
</head>
<body>
<pre id=res>output here</pre>
<script>
//const wallet = new libraweb.LibraWallet('student deliver dentist cat gorilla sleep proud naive gown fiber awkward weasel')
const client = new libraweb.LibraClient({
protocol: 'https',
host: 'ac-libra-testnet.kulap.io',
port: '443',
dataProtocol: 'grpc-web-text'
});
const address = new libraweb.AccountAddress(Uint8Array.from(
librawebBuffer.from('9291e14f5e7c1ce211ce9477154faddb0c308af2f6a10324f893e2e59a13ff80', 'hex')
))
//'9291e14f5e7c1ce211ce9477154faddb0c308af2f6a10324f893e2e59a13ff80'//wallet.getAccount(0).getAddress();
const accountState = client.getAccountState(address);
//async
accountState.then((value) => {
//outoput to DOM
res.innerHTML=
' address: ' + address
+'<hr> 残高: ' +value.balance
+'<hr> accountState: ' +JSON.stringify(value, null,4)
}, (reason) => {
res.innerHTML='err:'+reason
});
</script>
</body>
</html>