-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecipher2024.js
93 lines (78 loc) · 4.83 KB
/
decipher2024.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { blockStalkerClient, restClient, FilterFormBuilder, NumericCondition, KeyGroup, KeyType, KeyEvent } from '@blockstalker/client-js';
/*
███████╗███████╗████████╗██╗ ██╗██████╗
██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
███████╗█████╗ ██║ ██║ ██║██████╔╝
╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
███████║███████╗ ██║ ╚██████╔╝██║
╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝
*/
const local_apiKey = 'INSERT_YOUR_API_KEY_HERE';
// Note: If NodeJS > 20, we recommend using a .env file for your API key
const apiBaseURL = "https://api.blockstalker.io";
const apiKey = process.env.BLOCKSTALKER_API_KEY || local_apiKey;
const mainClient = blockStalkerClient(apiKey, apiBaseURL);
// Init RestClient, set `trace` to `false` for quieter operation
const rc = restClient(apiKey, apiBaseURL, { trace: true });
// Get Personal Stream
const streams = await rc.streams.owned();
const personalStream = streams.personal;
console.log("Personal stream:", personalStream);
/*
██╗ ██╗███████╗██████╗ ██████╗
██║ ██║██╔════╝██╔══██╗██╔════╝
██║ ██║███████╗██║ ██║██║
██║ ██║╚════██║██║ ██║██║
╚██████╔╝███████║██████╔╝╚██████╗
╚═════╝ ╚══════╝╚═════╝ ╚═════╝
*/
// Follow all USDC Transfers >= $5
const usdcFilter = new FilterFormBuilder()
.keyFilter('31566704', KeyEvent.AssetXfer)
.stream(personalStream)
.amount(5, NumericCondition.GreaterOrEqual)
.build();
await rc.filters.create(usdcFilter);
/*
██████╗ ██████╗ ██╗ ██╗
██╔════╝ ██╔═══██╗██║ ██║
██║ ███╗██║ ██║██║ ██║
██║ ██║██║ ██║╚██╗ ██╔╝
╚██████╔╝╚██████╔╝ ╚████╔╝
╚═════╝ ╚═════╝ ╚═══╝
*/
// Follow all Governance Voting Activity
const govFilter = new FilterFormBuilder()
.idFilter(KeyGroup.Governance, KeyType.Account)
.subscribe(KeyEvent.GovernanceTx)
.stream(personalStream)
.build();
await rc.filters.create(govFilter);
/*
███╗ ██╗███████╗████████╗
████╗ ██║██╔════╝╚══██╔══╝
██╔██╗ ██║█████╗ ██║
██║╚██╗██║██╔══╝ ██║
██║ ╚████║██║ ██║
╚═╝ ╚═══╝╚═╝ ╚═╝
*/
// Follow all Marketplace Listings for ALGOxNFT
const nftFilter = new FilterFormBuilder()
.keyFilter("XNFT36FUCFRR6CK675FW4BEBCCCOJ4HOSMGCN6J2W6ZMB34KM2ENTNQCP4")
.subscribe(KeyEvent.MarketplaceListing)
.stream(personalStream)
.build();
await rc.filters.create(nftFilter);
/*
███████╗████████╗██████╗ ███████╗ █████╗ ███╗ ███╗ ██╗████████╗██╗
██╔════╝╚══██╔══╝██╔══██╗██╔════╝██╔══██╗████╗ ████║ ██║╚══██╔══╝██║
███████╗ ██║ ██████╔╝█████╗ ███████║██╔████╔██║ ██║ ██║ ██║
╚════██║ ██║ ██╔══██╗██╔══╝ ██╔══██║██║╚██╔╝██║ ██║ ██║ ╚═╝
███████║ ██║ ██║ ██║███████╗██║ ██║██║ ╚═╝ ██║ ██║ ██║ ██╗
╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
*/
function handleEvent(event) {
// Handle your streaming events here
console.log(event);
}
const streamConnection = mainClient.streaming.events(handleEvent, [ personalStream ]);