-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.js
More file actions
25 lines (21 loc) · 839 Bytes
/
connect.js
File metadata and controls
25 lines (21 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env node
/**
* Connect to Quantova and read chain state (qweb3.js).
*
* Run:
* export QUANTOVA_RPC=http://127.0.0.1:9933 // or https://testnet.quantova.io
* node connect.js
*/
'use strict';
const { rpc, num, toQtov, banner } = require('./_common');
const ADDRESS = 'Qf2t7p9C5Im4waDJUgrrMqVt3Hs8=';
async function main() {
banner('Quantova: connect and read (qweb3.js)');
const block = num(await rpc('q_blockNumber'));
console.log(`Connected. Current block: ${block}`);
const rv = await rpc('state_getRuntimeVersion');
console.log(`Runtime: ${rv.specName} v${rv.specVersion} (tx v${rv.transactionVersion})`);
const bal = await rpc('q_getBalance', [ADDRESS]);
console.log(`Balance of ${ADDRESS}: ${toQtov(bal)} QTOV`);
}
main().catch((e) => { console.error('error:', e.message); process.exit(1); });