-
Notifications
You must be signed in to change notification settings - Fork 1
/
902_block_sample.html
63 lines (54 loc) · 1.51 KB
/
902_block_sample.html
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
59
60
61
62
63
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="nem2-sdk-0.13.1.js"></script>
<script>$(function() {
const nem = require("/node_modules/nem2-sdk");
const NODE = 'https://catapult-test.opening-line.jp:3001';
const blockHttp = new nem.BlockHttp(NODE);
const wsEndpoint = NODE.replace('https', 'wss');
const listener = new nem.Listener(wsEndpoint, WebSocket);
listener.open().then(() => {
listener
.newBlock()
.subscribe(function(_){
console.log("==new block==");
console.log(_.height.compact());
console.log(new Date(_.timestamp.compact() + Date.UTC(2016, 3, 1, 0, 0, 0, 0)));
blockHttp.getBlockTransactions(_.height.compact())
.subscribe((transactions) => {
console.log("--transaction--");
for(let transaction of transactions){
console.log(transaction);
}
})
blockHttp.getBlockReceipts(_.height.compact())
.subscribe((receipts) => {
console.log("--receipt--");
for(let statement of receipts.transactionStatements){
for(let receipt of statement.receipts){
console.log(receipt);
}
}
for(let statement of receipts.addressResolutionStatements){
for(let receipt of statement.receipts){
console.log(receipt);
}
}
for(let statement of receipts.mosaicResolutionStatements){
for(let receipt of statement.receipts){
console.log(receipt);
}
}
})
},
err => console.error(err));
});
})</script>
</head>
<body>
<h1>sample</h1>
</body>
</html>