-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ts
58 lines (51 loc) · 1.48 KB
/
example.ts
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as xcash from 'xcash';
const XCASH_DAEMON_ADDRESS:string = "127.0.0.1:18281";
const XCASH_WALLET_ADDRESS:string = "127.0.0.1:18285";
async function main() {
try {
await xcash.Initialize(XCASH_DAEMON_ADDRESS,XCASH_WALLET_ADDRESS);
const data:xcash.xcashInterfaces.BlockchainGetBlockCount = await xcash.Blockchain_get_block_count();
console.log(data.result.count); // prints 993163
console.log(JSON.stringify(data));
/* Prints out the following:
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"count": 993163,
"status": "OK",
"untrusted": "false"
}
}
*/
const dataAPI:xcash.xcashInterfaces.APIBlockchainStats = await xcash.API_Blockchain_stats();
console.log(dataAPI.height); // prints 810000
console.log(JSON.stringify(dataAPI));
/* Prints out the following:
{
"height": 810000,
"hash":"c7aa6eb38c47e7f013a5f8042477d1734ff9808fdc8608fb088085d624d2d509",
"reward": 20000000,
"size": 20000,
"version": 13,
"versionBlockHeight": 1000000,
"nextVersionBlockHeight": 0,
"totalPublicTx": 100000,
"totalPrivateTx": 100000,
"circulatingSupply": 10000000,
"generatedSupply": 100000000,
"totalSupply": 100000000,
"emissionReward": 1000000000,
"emissionHeight": 1000000000,
"emissionTime": 1000000000,
"inflationHeight": 1000000000,
"inflationTime": 1000000000
}
*/
}
catch (error)
{
console.log(error);
}
}
main();