@covalenthq/client-sdk 2.3.7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +578 -595
- package/dist/index.js +740 -994
- package/dist/index.js.map +1 -1
- package/dist/src/services/AllChainsService.d.ts +4 -14
- package/dist/src/services/BalanceService.d.ts +24 -10
- package/dist/src/services/BaseService.d.ts +23 -11
- package/dist/src/services/BitcoinService.d.ts +7 -1
- package/dist/src/services/NftService.d.ts +7 -147
- package/dist/src/services/PricingService.d.ts +5 -1
- package/dist/src/services/SecurityService.d.ts +3 -9
- package/dist/src/services/StreamingService.d.ts +78 -6
- package/dist/src/services/TransactionService.d.ts +15 -6
- package/dist/src/utils/types/BalanceService.types.d.ts +2 -12
- package/dist/src/utils/types/Generic.types.d.ts +13 -8
- package/dist/src/utils/types/NftService.types.d.ts +1 -281
- package/dist/src/utils/types/SecurityService.types.d.ts +0 -52
- package/dist/src/utils/types/StreamingService.types.d.ts +67 -6
- package/dist/src/utils/types/TransactionService.types.d.ts +2 -0
- package/package.json +7 -10
package/README.md
CHANGED
|
@@ -1,595 +1,578 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<a href="https://goldrush.dev/
|
|
3
|
-
<img alt="GoldRush TS SDK Logo" src="./repo-static/ts-sdk-banner.png" style="max-width: 100%;"/>
|
|
4
|
-
</a>
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<br/>
|
|
8
|
-
|
|
9
|
-
<p align="center">
|
|
10
|
-
<a href="https://www.npmjs.com/package/@covalenthq/client-sdk">
|
|
11
|
-
<img src="https://img.shields.io/npm/v/@covalenthq/client-sdk" alt="NPM">
|
|
12
|
-
</a>
|
|
13
|
-
<a href="https://www.npmjs.com/package/@covalenthq/client-sdk">
|
|
14
|
-
<img src="https://img.shields.io/npm/dm/@covalenthq/client-sdk" alt="NPM downloads">
|
|
15
|
-
</a>
|
|
16
|
-
<img src="https://img.shields.io/github/license/covalenthq/covalent-api-sdk-ts" alt="Apache-2.0">
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
# GoldRush SDK for TypeScript
|
|
20
|
-
|
|
21
|
-
The GoldRush SDK is the fastest way to integrate the GoldRush API for working with blockchain data. The SDK works with all [supported chains](https://
|
|
22
|
-
|
|
23
|
-
> Use with [`NodeJS v18`](https://nodejs.org/en) or above for best results.
|
|
24
|
-
|
|
25
|
-
> The GoldRush API is required. You can register for a free key on [GoldRush's website](https://goldrush.dev/platform/apikey)
|
|
26
|
-
|
|
27
|
-
## Using the SDK
|
|
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
|
-
2.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
contract_name
|
|
393
|
-
contract_ticker_symbol
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
</
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
</
|
|
475
|
-
|
|
476
|
-
<
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
- `
|
|
482
|
-
- `
|
|
483
|
-
- `
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
</
|
|
490
|
-
|
|
491
|
-
<
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
- `
|
|
497
|
-
- `
|
|
498
|
-
- `
|
|
499
|
-
- `
|
|
500
|
-
- `
|
|
501
|
-
- `
|
|
502
|
-
- `
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
</
|
|
509
|
-
|
|
510
|
-
<
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
</
|
|
519
|
-
|
|
520
|
-
<
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
- `
|
|
531
|
-
- `
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
- `
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
<
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
- `
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
<
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
- `
|
|
557
|
-
- `
|
|
558
|
-
- `
|
|
559
|
-
- `
|
|
560
|
-
- `
|
|
561
|
-
- `
|
|
562
|
-
- `
|
|
563
|
-
- `
|
|
564
|
-
|
|
565
|
-
</details>
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
- `rawQuery<T = Array<object>>(query: string, variables: Record<string, unknown>, callbacks: StreamSubscriptionOptions<T>): UnsubscribeFunction`: Execute custom GraphQL subscription queries for advanced streaming scenarios and future extensibility.
|
|
580
|
-
- `disconnect(): Promise<void>`: Properly disconnect from the streaming service.
|
|
581
|
-
|
|
582
|
-
</details>
|
|
583
|
-
|
|
584
|
-
## Contributing
|
|
585
|
-
|
|
586
|
-
Contributions, issues and feature requests are welcome!
|
|
587
|
-
Feel free to check [issues](https://github.com/covalenthq/covalent-api-sdk-ts/issues) page.
|
|
588
|
-
|
|
589
|
-
## Show your support
|
|
590
|
-
|
|
591
|
-
Give a ⭐️ if this project helped you!
|
|
592
|
-
|
|
593
|
-
## License
|
|
594
|
-
|
|
595
|
-
This project is [MIT](./LICENSE) licensed.
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://goldrush.dev/" target="_blank" rel="noopener noreferrer">
|
|
3
|
+
<img alt="GoldRush TS SDK Logo" src="./repo-static/ts-sdk-banner.png" style="max-width: 100%;"/>
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<br/>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@covalenthq/client-sdk">
|
|
11
|
+
<img src="https://img.shields.io/npm/v/@covalenthq/client-sdk" alt="NPM">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@covalenthq/client-sdk">
|
|
14
|
+
<img src="https://img.shields.io/npm/dm/@covalenthq/client-sdk" alt="NPM downloads">
|
|
15
|
+
</a>
|
|
16
|
+
<img src="https://img.shields.io/github/license/covalenthq/covalent-api-sdk-ts" alt="Apache-2.0">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
# GoldRush SDK for TypeScript
|
|
20
|
+
|
|
21
|
+
The GoldRush SDK is the fastest way to integrate the GoldRush API for working with blockchain data. The SDK works with all [supported chains](https://goldrush.dev/chains/) including Mainnets and Testnets.
|
|
22
|
+
|
|
23
|
+
> Use with [`NodeJS v18`](https://nodejs.org/en) or above for best results.
|
|
24
|
+
|
|
25
|
+
> The GoldRush API Key is required. You can register for a free key on [GoldRush's website](https://goldrush.dev/platform/apikey)
|
|
26
|
+
|
|
27
|
+
## Using the SDK
|
|
28
|
+
|
|
29
|
+
1. Install the dependencies
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @covalenthq/client-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. Create a client using the `GoldRushClient`
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { GoldRushClient, Chains } from "@covalenthq/client-sdk";
|
|
39
|
+
|
|
40
|
+
const client = new GoldRushClient("<YOUR_API_KEY>");
|
|
41
|
+
|
|
42
|
+
const ApiServices = async () => {
|
|
43
|
+
try {
|
|
44
|
+
const balanceResp =
|
|
45
|
+
await client.BalanceService.getTokenBalancesForWalletAddress(
|
|
46
|
+
"eth-mainnet",
|
|
47
|
+
"0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (balanceResp.error) {
|
|
51
|
+
throw balanceResp;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.log(balanceResp.data);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(error);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The `GoldRushClient` can be configured with a second object argument, `settings`, and a third argument for `streamingConfig`. The settings offered are
|
|
62
|
+
1. **debug**: A boolean that enables server logs of the API calls, enhanced with the request URL, response time and code, and other settings. It is set as `false` by default.
|
|
63
|
+
2. **threadCount**: A number that sets the number of concurrent requests allowed. It is set as `2` by default.
|
|
64
|
+
3. **enableRetry**: A boolean that enables retrying the API endpoint in case of a `429 - rate limit` error. It is set as `true` by default.
|
|
65
|
+
4. **maxRetries**: A number that sets the number of retries to be made in case of `429 - rate limit` error. To be in effect, it requires `enableRetry` to be enabled. It is set as `2` by default.
|
|
66
|
+
5. **retryDelay**: A number that sets the delay in `ms` for retrying the API endpoint in case of `429 - rate limit` error. To be in effect, it requires `enableRetry` to be enabled. It is set as `2` by default.
|
|
67
|
+
6. **source**: A string that defines the `source` of the request of better analytics.
|
|
68
|
+
|
|
69
|
+
The `streamingConfig` is optional and configures the real-time streaming service. The available options are:
|
|
70
|
+
1. **shouldRetry**: A function that determines whether to retry connection based on retry count. Defaults to retry up to 5 times.
|
|
71
|
+
2. **maxReconnectAttempts**: Maximum number of reconnection attempts. Defaults to `5`.
|
|
72
|
+
3. **onConnecting**: Callback function triggered when connecting to the streaming service.
|
|
73
|
+
4. **onOpened**: Callback function triggered when connection is successfully established.
|
|
74
|
+
5. **onClosed**: Callback function triggered when connection is closed.
|
|
75
|
+
6. **onError**: Callback function triggered when an error occurs.
|
|
76
|
+
|
|
77
|
+
## Features
|
|
78
|
+
|
|
79
|
+
### 1. Name Resolution
|
|
80
|
+
|
|
81
|
+
The GoldRush SDK natively resolves the underlying wallet address for the following
|
|
82
|
+
|
|
83
|
+
1. ENS Domains (e.g. `demo.eth`)
|
|
84
|
+
2. Lens Handles (e.g. `demo.lens`)
|
|
85
|
+
3. Unstoppable Domains (e.g. `demo.x`)
|
|
86
|
+
4. RNS Domains (e.g. `demo.ron`)
|
|
87
|
+
|
|
88
|
+
### 2. Query Parameters
|
|
89
|
+
|
|
90
|
+
All the API call arguments have an option to pass `typed objects` as Query parameters.
|
|
91
|
+
|
|
92
|
+
For example, the following sets the `quoteCurrency` query parameter to `CAD` and the parameter `nft` to `true` for fetching all the token balances, including NFTs, for a wallet address:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const resp = await client.BalanceService.getTokenBalancesForWalletAddress(
|
|
96
|
+
"eth-mainnet",
|
|
97
|
+
"0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de",
|
|
98
|
+
{
|
|
99
|
+
quoteCurrency: "CAD",
|
|
100
|
+
nft: true,
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 3. Exported Types
|
|
106
|
+
|
|
107
|
+
All the `interface`s used, for arguments, query parameters and responses are also exported from the package which can be used for custom usage.
|
|
108
|
+
|
|
109
|
+
For example, explicitly typecasting the response
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import {
|
|
113
|
+
GoldRushClient,
|
|
114
|
+
type BalancesResponse,
|
|
115
|
+
type BalanceItem,
|
|
116
|
+
} from "@covalenthq/client-sdk";
|
|
117
|
+
|
|
118
|
+
const resp = await client.BalanceService.getTokenBalancesForWalletAddress(
|
|
119
|
+
"eth-mainnet",
|
|
120
|
+
"0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de",
|
|
121
|
+
{
|
|
122
|
+
quoteCurrency: "CAD",
|
|
123
|
+
nft: true,
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const data: BalancesResponse = resp.data;
|
|
128
|
+
const items: BalanceItem[] = resp.data.items;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 4. Multiple Chain input formats
|
|
132
|
+
|
|
133
|
+
The SDK supports the following formats for the chain input:
|
|
134
|
+
|
|
135
|
+
1. Chain Name (e.g. `eth-mainnet`)
|
|
136
|
+
2. Chain ID (e.g. `1`)
|
|
137
|
+
3. Chain Name Enum (e.g. `ChainName.ETH_MAINNET`)
|
|
138
|
+
4. Chain ID Enum (e.g. `ChainID.ETH_MAINNET`)
|
|
139
|
+
|
|
140
|
+
### 5. Additional Non-Paginated methods
|
|
141
|
+
|
|
142
|
+
For paginated responses, the GoldRush API can at max support 100 items per page. However, the Covalent SDK leverages generators to _seamlessly fetch all items without the user having to deal with pagination_.
|
|
143
|
+
|
|
144
|
+
For example, the following fetches ALL transactions for `0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de` on Ethereum:
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { GoldRushClient } from "@covalenthq/client-sdk";
|
|
148
|
+
|
|
149
|
+
const ApiServices = async () => {
|
|
150
|
+
const client = new GoldRushClient("<YOUR_API_KEY>");
|
|
151
|
+
try {
|
|
152
|
+
for await (const tx of client.TransactionService.getAllTransactionsForAddress(
|
|
153
|
+
"eth-mainnet",
|
|
154
|
+
"0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
|
|
155
|
+
)) {
|
|
156
|
+
console.log("tx", tx);
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.log(error.message);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 6. Executable pagination functions
|
|
165
|
+
|
|
166
|
+
Paginated methods have been enhanced with the introduction of `next()` and `prev()` support functions. These functions facilitate a smoother transition for developers navigating through our `links` object, which includes `prev` and `next` fields. Instead of requiring developers to manually extract values from these fields and create JavaScript API fetch calls for the URL values, the new `next()` and `prev()` functions provide a streamlined approach, allowing developers to simulate this behavior more efficiently.
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { GoldRushClient } from "@covalenthq/client-sdk";
|
|
170
|
+
|
|
171
|
+
const client = new GoldRushClient("<YOUR_API_KEY>");
|
|
172
|
+
const resp = await client.TransactionService.getAllTransactionsForAddressByPage(
|
|
173
|
+
"eth-mainnet",
|
|
174
|
+
"0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
|
|
175
|
+
); // assuming resp.data.current_page is 10
|
|
176
|
+
if (resp.data !== null) {
|
|
177
|
+
const prevPage = await resp.data.prev(); // will retrieve page 9
|
|
178
|
+
console.log(prevPage.data);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 7. Utility Functions
|
|
183
|
+
|
|
184
|
+
1. **bigIntParser**: Formats input as a `bigint` value. For example
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
bigIntParser("-123"); // -123n
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
You can explore more examples [here](./test/unit/bigint-parser.test.ts)
|
|
191
|
+
|
|
192
|
+
2. **calculatePrettyBalance**: Formats large and raw numbers and bigints to human friendly format. For example
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
calculatePrettyBalance(1.5, 3, true, 4); // "0.0015"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
You can explore more examples [here](./test/unit/calculate-pretty-balance.test.ts)
|
|
199
|
+
|
|
200
|
+
3. **isValidApiKey**: Checks for the input as a valid GoldRush API Key. For example
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
isValidApiKey(cqt_wF123); // false
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
You can explore more examples [here](./test/unit/is-valid-api-key.test.ts)
|
|
207
|
+
|
|
208
|
+
4. **prettifyCurrency**: Formats large and raw numbers and bigints to human friendly currency format. For example
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
prettifyCurrency(89.0, 2, "CAD"); // "CA$89.00"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
You can explore more examples [here](./test/unit/is-valid-api-key.test.ts)
|
|
215
|
+
|
|
216
|
+
5. **timestampParser**: Convert ISO timestamps to various human-readable formats
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
timestampParser("2024-10-16T12:39:23.000Z", "descriptive"); // "October 16 2024 at 18:09:23"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
You can explore more examples [here](./test/unit/timestamp-parser.test.ts)
|
|
223
|
+
|
|
224
|
+
### 8. Real-time Streaming
|
|
225
|
+
|
|
226
|
+
The GoldRush SDK now supports real-time streaming of blockchain data via WebSocket connections. This allows you to subscribe to live data feeds for OHLCV (Open, High, Low, Close, Volume) data for trading pairs and tokens, new DEX pair creations, wallet activity, and more.
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import {
|
|
230
|
+
GoldRushClient,
|
|
231
|
+
StreamingChain,
|
|
232
|
+
StreamingInterval,
|
|
233
|
+
StreamingTimeframe,
|
|
234
|
+
StreamingProtocol,
|
|
235
|
+
} from "@covalenthq/client-sdk";
|
|
236
|
+
|
|
237
|
+
const client = new GoldRushClient(
|
|
238
|
+
"<YOUR_API_KEY>",
|
|
239
|
+
{},
|
|
240
|
+
{
|
|
241
|
+
onConnecting: () => console.log("Connecting to streaming service..."),
|
|
242
|
+
onOpened: () => console.log("Connected to streaming service!"),
|
|
243
|
+
onClosed: () => console.log("Disconnected from streaming service"),
|
|
244
|
+
onError: (error) => console.error("Streaming error:", error),
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
// Subscribe to OHLCV data for trading pairs
|
|
249
|
+
const unsubscribePairs = client.StreamingService.subscribeToOHLCVPairs(
|
|
250
|
+
{
|
|
251
|
+
chain_name: StreamingChain.BASE_MAINNET,
|
|
252
|
+
pair_addresses: ["0x9c087Eb773291e50CF6c6a90ef0F4500e349B903"],
|
|
253
|
+
interval: StreamingInterval.ONE_MINUTE,
|
|
254
|
+
timeframe: StreamingTimeframe.ONE_HOUR,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
next: (data) => {
|
|
258
|
+
console.log("Received OHLCV pair data:", data);
|
|
259
|
+
},
|
|
260
|
+
error: (error) => {
|
|
261
|
+
console.error("Streaming error:", error);
|
|
262
|
+
},
|
|
263
|
+
complete: () => {
|
|
264
|
+
console.log("Stream completed");
|
|
265
|
+
},
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
// Unsubscribe when done
|
|
270
|
+
// unsubscribePairs();
|
|
271
|
+
|
|
272
|
+
// Disconnect from streaming service when finished
|
|
273
|
+
// await client.StreamingService.disconnect();
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Multiple Subscriptions
|
|
277
|
+
|
|
278
|
+
The SDK uses a singleton WebSocket client internally, allowing you to create multiple subscriptions through the same `GoldRushClient`.
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
// Create a single client
|
|
282
|
+
const client = new GoldRushClient("<YOUR_API_KEY>");
|
|
283
|
+
|
|
284
|
+
// Create multiple subscriptions through the same connection
|
|
285
|
+
const unsubscribePairs = client.StreamingService.subscribeToOHLCVPairs(
|
|
286
|
+
{
|
|
287
|
+
chain_name: StreamingChain.BASE_MAINNET,
|
|
288
|
+
pair_addresses: ["0x9c087Eb773291e50CF6c6a90ef0F4500e349B903"],
|
|
289
|
+
interval: StreamingInterval.ONE_MINUTE,
|
|
290
|
+
timeframe: StreamingTimeframe.ONE_HOUR,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
next: (data) => console.log("OHLCV Pairs:", data),
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const unsubscribeTokens = client.StreamingService.subscribeToOHLCVTokens(
|
|
298
|
+
{
|
|
299
|
+
chain_name: StreamingChain.BASE_MAINNET,
|
|
300
|
+
token_addresses: ["0x4B6104755AfB5Da4581B81C552DA3A25608c73B8"],
|
|
301
|
+
interval: StreamingInterval.ONE_MINUTE,
|
|
302
|
+
timeframe: StreamingTimeframe.ONE_HOUR,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
next: (data) => console.log("OHLCV Tokens:", data),
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
const unsubscribeWallet = client.StreamingService.subscribeToWalletActivity(
|
|
310
|
+
{
|
|
311
|
+
chain_name: StreamingChain.BASE_MAINNET,
|
|
312
|
+
wallet_addresses: ["0xbaed383ede0e5d9d72430661f3285daa77e9439f"],
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
next: (data) => console.log("Wallet Activity:", data),
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
// Unsubscribe from individual streams when needed
|
|
320
|
+
// unsubscribePairs();
|
|
321
|
+
// unsubscribeTokens();
|
|
322
|
+
// unsubscribeWallet();
|
|
323
|
+
|
|
324
|
+
// Or disconnect from all streams at once
|
|
325
|
+
// await client.StreamingService.disconnect();
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
#### React Integration
|
|
329
|
+
|
|
330
|
+
For React applications, use the `useEffect` hook to properly manage subscription lifecycle:
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
const unsubscribe = client.StreamingService.rawQuery(
|
|
335
|
+
`subscription {
|
|
336
|
+
ohlcvCandlesForPair(
|
|
337
|
+
chain_name: BASE_MAINNET
|
|
338
|
+
pair_addresses: ["0x9c087Eb773291e50CF6c6a90ef0F4500e349B903"],
|
|
339
|
+
interval: StreamingInterval.ONE_MINUTE,
|
|
340
|
+
timeframe: StreamingTimeframe.ONE_HOUR,
|
|
341
|
+
) {
|
|
342
|
+
open
|
|
343
|
+
high
|
|
344
|
+
low
|
|
345
|
+
close
|
|
346
|
+
volume
|
|
347
|
+
quote_rate
|
|
348
|
+
volume_usd
|
|
349
|
+
chain_name
|
|
350
|
+
pair_address
|
|
351
|
+
interval
|
|
352
|
+
timeframe
|
|
353
|
+
timestamp
|
|
354
|
+
}
|
|
355
|
+
}`,
|
|
356
|
+
{},
|
|
357
|
+
{
|
|
358
|
+
next: (data) => console.log("Received streaming data:", data),
|
|
359
|
+
error: (err) => console.error("Subscription error:", err),
|
|
360
|
+
complete: () => console.info("Subscription completed"),
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
// Cleanup function - unsubscribe when component unmounts
|
|
365
|
+
return () => {
|
|
366
|
+
unsubscribe();
|
|
367
|
+
};
|
|
368
|
+
}, []);
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
#### Raw Queries
|
|
372
|
+
|
|
373
|
+
You can also use raw GraphQL queries for more streamlined and selective data scenarios:
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
const unsubscribeNewPairs = client.StreamingService.rawQuery(
|
|
377
|
+
`subscription {
|
|
378
|
+
newPairs(
|
|
379
|
+
chain_name: BASE_MAINNET,
|
|
380
|
+
protocols: [UNISWAP_V2, UNISWAP_V3]
|
|
381
|
+
) {
|
|
382
|
+
chain_name
|
|
383
|
+
protocol
|
|
384
|
+
pair_address
|
|
385
|
+
tx_hash
|
|
386
|
+
liquidity
|
|
387
|
+
base_token {
|
|
388
|
+
contract_name
|
|
389
|
+
contract_ticker_symbol
|
|
390
|
+
}
|
|
391
|
+
quote_token {
|
|
392
|
+
contract_name
|
|
393
|
+
contract_ticker_symbol
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}`,
|
|
397
|
+
{},
|
|
398
|
+
{
|
|
399
|
+
next: (data) => console.log("Raw new pairs data:", data),
|
|
400
|
+
error: (error) => console.error("Error:", error),
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
// Raw query for token OHLCV data
|
|
405
|
+
const unsubscribeTokenOHLCV = client.StreamingService.rawQuery(
|
|
406
|
+
`subscription {
|
|
407
|
+
ohlcvCandlesForToken(
|
|
408
|
+
chain_name: BASE_MAINNET
|
|
409
|
+
token_addresses: ["0x4B6104755AfB5Da4581B81C552DA3A25608c73B8"]
|
|
410
|
+
interval: ONE_MINUTE
|
|
411
|
+
timeframe: ONE_HOUR
|
|
412
|
+
) {
|
|
413
|
+
open
|
|
414
|
+
high
|
|
415
|
+
low
|
|
416
|
+
close
|
|
417
|
+
volume
|
|
418
|
+
volume_usd
|
|
419
|
+
quote_rate
|
|
420
|
+
quote_rate_usd
|
|
421
|
+
timestamp
|
|
422
|
+
base_token {
|
|
423
|
+
contract_name
|
|
424
|
+
contract_ticker_symbol
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}`,
|
|
428
|
+
{},
|
|
429
|
+
{
|
|
430
|
+
next: (data) => console.log("Raw token OHLCV data:", data),
|
|
431
|
+
error: (error) => console.error("Error:", error),
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### 9. Standardized (Error) Responses
|
|
437
|
+
|
|
438
|
+
All the responses are of the same standardized format
|
|
439
|
+
|
|
440
|
+
```ts
|
|
441
|
+
❴
|
|
442
|
+
"data": <object>,
|
|
443
|
+
"error": <boolean>,
|
|
444
|
+
"error_message": <string>,
|
|
445
|
+
"error_code": <number>
|
|
446
|
+
❵
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Supported Endpoints
|
|
450
|
+
|
|
451
|
+
The Covalent SDK provides comprehensive support for all Class A, Class B, and Pricing endpoints that are grouped under the following _Service_ namespaces:
|
|
452
|
+
|
|
453
|
+
<details>
|
|
454
|
+
<summary>
|
|
455
|
+
1. <strong>All Chains Service</strong>: Access to the data across multiple chains and addresses.
|
|
456
|
+
</summary>
|
|
457
|
+
|
|
458
|
+
- `getAddressActivity(walletAddress: string, queryParamOpts?: GetAddressActivityQueryParamOpts): Promise<GoldRushResponse<ChainActivityResponse>>`: Commonly used to locate chains which an address is active on with a single API call.
|
|
459
|
+
- `getMultiChainMultiAddressTransactions(queryParamOpts?: GetMultiChainMultiAddressTransactionsParamOtps): Promise<GoldRushResponse<MultiChainMultiAddressTransactionsResponse>>`: Fetch paginated transactions for up to 10 EVM addresses and 10 EVM chains with one API call. Useful for building Activity Feeds.
|
|
460
|
+
- `getMultiChainBalances(walletAddress: string, queryParamOpts?: GetMultiChainBalanceQueryParamOpts): Promise<GoldRushResponse<MultiChainBalanceResponse>>`: Fetch paginated spot & historical native and token balances for a single address on up to 10 EVM chains with one API call.
|
|
461
|
+
</details>
|
|
462
|
+
|
|
463
|
+
<details>
|
|
464
|
+
<summary>
|
|
465
|
+
2. <strong>Security Service</strong>: Access to the token approvals API endpoints
|
|
466
|
+
</summary>
|
|
467
|
+
|
|
468
|
+
- `getApprovals(chainName: Chain, walletAddress: string): Promise<GoldRushResponse<ApprovalsResponse>>`: Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet's assets.
|
|
469
|
+
</details>
|
|
470
|
+
|
|
471
|
+
<details>
|
|
472
|
+
<summary>
|
|
473
|
+
3. <strong>Balance Service</strong>: Access to the balances endpoints
|
|
474
|
+
</summary>
|
|
475
|
+
|
|
476
|
+
- `getTokenBalancesForWalletAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetTokenBalancesForWalletAddressQueryParamOpts): Promise<GoldRushResponse<BalancesResponse>>`: Commonly used to fetch the native and fungible (ERC20) tokens held by an address. Response includes spot prices and other metadata.
|
|
477
|
+
- `getHistoricalTokenBalancesForWalletAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetHistoricalTokenBalancesForWalletAddressQueryParamOpts): Promise<GoldRushResponse<HistoricalBalancesResponse>>`: Commonly used to fetch the historical native and fungible (ERC20) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
|
|
478
|
+
- `getHistoricalPortfolioForWalletAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetHistoricalPortfolioForWalletAddressQueryParamOpts): Promise<GoldRushResponse<PortfolioResponse>>`: Commonly used to render a daily portfolio balance for an address broken down by the token. The timeframe is user-configurable, defaults to 30 days.
|
|
479
|
+
- `getErc20TransfersForWalletAddress(chainName: Chain, walletAddress: string, queryParamOpts: GetErc20TransfersForWalletAddressQueryParamOpts): AsyncIterable<GoldRushResponse<Erc20TransfersResponse>>`: Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address. (Paginated)
|
|
480
|
+
- `getErc20TransfersForWalletAddressByPage(chainName: Chain, walletAddress: string, queryParamOpts: GetErc20TransfersForWalletAddressQueryParamOpts): Promise<GoldRushResponse<Erc20TransfersResponse>>`: Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address. (Nonpaginated)
|
|
481
|
+
- `getTokenHoldersV2ForTokenAddress(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): AsyncIterable<GoldRushResponse<TokenHoldersResponse>>`: Used to get a paginated list of current or historical token holders for a specified ERC20 or ERC721 token. (Paginated)
|
|
482
|
+
- `getTokenHoldersV2ForTokenAddressByPage(chainName: Chain, tokenAddress: string, queryParamOpts?: GetTokenHoldersV2ForTokenAddressQueryParamOpts): Promise<GoldRushResponse<TokenHoldersResponse>>`: Used to get a paginated list of current or historical token holders for a specified ERC20 or ERC721 token. (Nonpaginated)
|
|
483
|
+
- `getNativeTokenBalance(chainName: Chain, walletAddress: string, queryParamOpts?: GetNativeTokenBalanceQueryParamOpts): Promise<GoldRushResponse<TokenBalanceNativeResponse>>`: Lightweight endpoint to just get the native token balance for an EVM address.
|
|
484
|
+
</details>
|
|
485
|
+
|
|
486
|
+
<details>
|
|
487
|
+
<summary>
|
|
488
|
+
4. <strong>Base Service</strong>: Access to the address activity, log events, chain status, and block retrieval endpoints
|
|
489
|
+
</summary>
|
|
490
|
+
|
|
491
|
+
- `getBlock(chainName: Chain, blockHeight: string): Promise<GoldRushResponse<BlockResponse>>`: Commonly used to fetch and render a single block for a block explorer.
|
|
492
|
+
- `getLogs(chainName: Chain, queryParamOpts?: GetLogsQueryParamOpts): Promise<GoldRushResponse<GetLogsResponse>>`: Commonly used to get all the event logs of the latest block, or for a range of blocks. Includes sender contract metadata as well as decoded logs.
|
|
493
|
+
- `getResolvedAddress(chainName: Chain, walletAddress: string): Promise<GoldRushResponse<ResolvedAddress>>`: Commonly used to resolve ENS, RNS and Unstoppable Domains addresses. Only supports the resolution of a registered domain to an address.
|
|
494
|
+
- `getBlockHeights(chainName: Chain, startDate: string, endDate: string | "latest", queryParamOpts?: GetBlockHeightsQueryParamOpts): AsyncIterable<GoldRushResponse<BlockHeightsResponse>>`: Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day. (Paginated)
|
|
495
|
+
- `getBlockHeightsByPage(chainName: Chain, startDate: string, endDate: string | "latest", queryParamOpts?: GetBlockHeightsQueryParamOpts): Promise<GoldRushResponse<BlockHeightsResponse>>`: Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day. (Nonpaginated)
|
|
496
|
+
- `getLogEventsByAddress(chainName: Chain, contractAddress: string, queryParamOpts?: GetLogEventsByAddressQueryParamOpts): AsyncIterable<GoldRushResponse<LogEventsByAddressResponse>>`: Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions. (Paginated)
|
|
497
|
+
- `getLogEventsByAddressByPage(chainName: Chain, contractAddress: string, queryParamOpts?: GetLogEventsByAddressQueryParamOpts): Promise<GoldRushResponse<LogEventsByAddressResponse>>`: Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions. (Nonpaginated)
|
|
498
|
+
- `getLogEventsByTopicHash(chainName: Chain, topicHash: string, queryParamOpts?: GetLogEventsByTopicHashQueryParamOpts): AsyncIterable<GoldRushResponse<LogEventsByTopicHashResponse>>`: Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain. (Paginated)
|
|
499
|
+
- `getLogEventsByTopicHashByPage(chainName: Chain, topicHash: string, queryParamOpts?: GetLogEventsByTopicHashQueryParamOpts): Promise<GoldRushResponse<LogEventsByTopicHashResponse>>`: Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain. (Nonpaginated)
|
|
500
|
+
- `getAllChains(): Promise<GoldRushResponse<AllChainsResponse>>`: Commonly used to build internal dashboards for all supported chains on Covalent.
|
|
501
|
+
- `getAllChainStatus(): Promise<GoldRushResponse<AllChainStatusResponse>>`: Commonly used to build internal status dashboards of all supported chains.
|
|
502
|
+
- `getGasPrices(chainName: Chain, eventType: "erc20" | "nativetokens" | "uniswapv3", queryParamOpts?: GetGasPricesQueryParamOpts): Promise<GoldRushResponse<GasPricesResponse>>`: Get real-time gas estimates for different transaction speeds on a specific network, enabling users to optimize transaction costs and confirmation times.
|
|
503
|
+
</details>
|
|
504
|
+
|
|
505
|
+
<details>
|
|
506
|
+
<summary>
|
|
507
|
+
5. <strong>Bitcoin Service</strong>: Access to the Bitcoin wallet endpoints
|
|
508
|
+
</summary>
|
|
509
|
+
|
|
510
|
+
- `getBitcoinHdWalletBalances(walletAddress: string, queryParamOpts?: GetBitcoinHdWalletBalancesQueryParamOpts): Promise<GoldRushResponse<BitcoinHdWalletBalancesResponse>>`: Commonly used to fetch the historical Bitcoin balance held by an address at a given block height or date. Response includes daily prices and other metadata.
|
|
511
|
+
- `getBitcoinNonHdWalletBalances(walletAddress: string, queryParamOpts?: GetBitcoinNonHdWalletBalancesQueryParamOpts): Promise<GoldRushResponse<BalancesResponse>>`: Fetch Bitcoin balance for a non-HD address. Response includes spot prices and other metadata.
|
|
512
|
+
- `getTransactionsForBtcAddress(queryParamOpts?: GetTransactionsForBitcoinAddressParamOpts): Promise<GoldRushResponse<BitcoinTransactionResponse>>`: Used to fetch the full transaction history of a Bitcoin non-HD wallet address.
|
|
513
|
+
</details>
|
|
514
|
+
|
|
515
|
+
<details>
|
|
516
|
+
<summary>
|
|
517
|
+
6. <strong>NFT Service</strong>: Access to the NFT endpoints
|
|
518
|
+
</summary>
|
|
519
|
+
|
|
520
|
+
- `getNftsForAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetNftsForAddressQueryParamOpts): Promise<GoldRushResponse<NftAddressBalanceNftResponse>>`: Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
|
|
521
|
+
- `checkOwnershipInNft(chainName: Chain, walletAddress: string, collectionContract: string, queryParamOpts?: CheckOwnershipInNftQueryParamOpts): Promise<GoldRushResponse<NftOwnershipForCollectionResponse>>`: Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
|
|
522
|
+
- `checkOwnershipInNftForSpecificTokenId(chainName: Chain, walletAddress: string, collectionContract: string, tokenId: string): Promise<GoldRushResponse<NftOwnershipForCollectionResponse>>`: Commonly used to verify ownership of a specific token (ERC-721 or ERC-1155) within a collection.
|
|
523
|
+
</details>
|
|
524
|
+
|
|
525
|
+
<details>
|
|
526
|
+
<summary>
|
|
527
|
+
7. <strong>Pricing Service</strong>: Access to the historical token prices endpoint
|
|
528
|
+
</summary>
|
|
529
|
+
|
|
530
|
+
- `getTokenPrices(chainName: Chain, quoteCurrency: Quote, contractAddress: string, queryParamOpts?: GetTokenPricesQueryParamOpts): Promise<GoldRushResponse<TokenPricesResponse[]>>`: Get the historical prices of one (or many) large cap ERC20 tokens between specified date ranges. Also supports native tokens.
|
|
531
|
+
- `getPoolSpotPrices(chainName: Chain, contractAddress: string, queryParamOpts?: PoolSpotPriceQueryParamsOpts): Promise<GoldRushResponse<PoolSpotPricesResponse[]>>`: Get the spot token pair prices for a specified pool contract address. Supports pools on Uniswap V2, V3 and their forks.
|
|
532
|
+
</details>
|
|
533
|
+
|
|
534
|
+
<details>
|
|
535
|
+
<summary>
|
|
536
|
+
8. <strong>Transaction Service</strong>: Access to the transactions endpoints
|
|
537
|
+
</summary>
|
|
538
|
+
|
|
539
|
+
- `getAllTransactionsForAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetAllTransactionsForAddressQueryParamOpts): AsyncIterable<GoldRushResponse<RecentTransactionsResponse>>`: Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications. (Paginated)
|
|
540
|
+
- `getAllTransactionsForAddressByPage(chainName: Chain, walletAddress: string, queryParamOpts?: GetAllTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<RecentTransactionsResponse>>`: Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications. (Nonpaginated)
|
|
541
|
+
- `getPaginatedTransactionsForAddress(chainName: Chain, walletAddress: string, page: number, queryParamOpts?: getPaginatedTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<TransactionsResponse>>`: Commonly used to fetch the transactions involving an address including the decoded log events in a paginated fashion.
|
|
542
|
+
- `getTransaction(chainName: Chain, txHash: string, queryParamOpts?: GetTransactionQueryParamOpts): Promise<GoldRushResponse<TransactionResponse>>`: Used to fetch and render a single transaction including its decoded event logs. For foundational chains, can also retrieve internal transactions, state changes and method ID where available.
|
|
543
|
+
- `getTransactionsForBlockByPage(chainName: Chain, blockHeight: number | string | "latest", page: number, queryParamOpts?: getTransactionsForBlockByPageQueryParamOpts): Promise<GoldRushResponse<TransactionsBlockResponse>>`: Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
544
|
+
- `getTransactionsForBlock(chainName: Chain, blockHash: string, queryParamOpts?: getTransactionsForBlockByPageQueryParamOpts): Promise<GoldRushResponse<TransactionsForBlockResponse>>`: Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
|
|
545
|
+
- `getTransactionSummary(chainName: Chain, walletAddress: string, queryParamOpts?: GetTransactionSummaryQueryParamOpts): Promise<GoldRushResponse<TransactionsSummaryResponse>>`: Used to fetch the earliest and latest transactions, and the transaction count for a wallet. Also enriched with gas expenditure details and total ERC20 token transfers count.
|
|
546
|
+
- `getTimeBucketTransactionsForAddress(chainName: Chain, walletAddress: string, timeBucket: number, queryParamOpts?: GetTimeBucketTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<TransactionsTimeBucketResponse>>`: Commonly used to fetch all transactions including their decoded log events in a 15-minute time bucket interval.
|
|
547
|
+
- `getEarliestTransactionsForAddress(chainName: Chain, walletAddress: string, queryParamOpts?: GetEarliestTransactionsForAddressQueryParamOpts): Promise<GoldRushResponse<EarliestTransactionsForAddressResponse>>`: Commonly used to fetch and render the earliest transactions involving an address. Frequently seen in wallet applications.
|
|
548
|
+
</details>
|
|
549
|
+
|
|
550
|
+
<details>
|
|
551
|
+
<summary>
|
|
552
|
+
9. <strong>Streaming Service</strong>: Real-time blockchain data streaming via WebSocket connections
|
|
553
|
+
</summary>
|
|
554
|
+
|
|
555
|
+
- `getClient(): Client`: Get the underlying GraphQL WebSocket client for direct access.
|
|
556
|
+
- `isConnected: boolean`: Check the connection status of the streaming service.
|
|
557
|
+
- `subscribeToOHLCVPairs(params: OHLCVPairsStreamParams, callbacks: StreamSubscriptionOptions<OHLCVPairsStreamResponse[]>): UnsubscribeFunction`: Subscribe to real-time OHLCV (Open, High, Low, Close, Volume) data for specific trading pairs. Supports multiple chains and configurable intervals and timeframes.
|
|
558
|
+
- `subscribeToOHLCVTokens(params: OHLCVTokensStreamParams, callbacks: StreamSubscriptionOptions<OHLCVTokensStreamResponse[]>): UnsubscribeFunction`: Subscribe to real-time OHLCV (Open, High, Low, Close, Volume) data for specific tokens. Tracks token prices across their primary DEX pools with configurable intervals and timeframes.
|
|
559
|
+
- `subscribeToWalletActivity(params: WalletActivityStreamParams, callbacks: StreamSubscriptionOptions<WalletActivityStreamResponse[]>): UnsubscribeFunction`: Subscribe to real-time wallet activity including transactions, token transfers, and smart contract interactions. Provides decoded transaction details for swaps, transfers, bridges, deposits, withdrawals, and approvals.
|
|
560
|
+
- `subscribeToNewPairs(params: NewPairsStreamParams, callbacks: StreamSubscriptionOptions<NewPairsStreamResponse[]>): UnsubscribeFunction`: Subscribe to real-time notifications when new liquidity pairs are created on supported decentralized exchanges (DEXes). Supports Uniswap V2/V3 across Base, Ethereum, and BSC networks.
|
|
561
|
+
- `subscribeToUpdatePairs(params: UpdatePairsStreamParams, callbacks: StreamSubscriptionOptions<UpdatePairsStreamResponse>): UnsubscribeFunction`: Subscribe to real-time updates for specific trading pairs including quote rate, volume, liquidity data, price deltas, and swap counts.
|
|
562
|
+
- `rawQuery<T = Array<object>>(query: string, variables: Record<string, unknown>, callbacks: StreamSubscriptionOptions<T>): UnsubscribeFunction`: Execute custom GraphQL subscription queries for advanced streaming scenarios and future extensibility.
|
|
563
|
+
- `disconnect(): Promise<void>`: Properly disconnect from the streaming service.
|
|
564
|
+
|
|
565
|
+
</details>
|
|
566
|
+
|
|
567
|
+
## Contributing
|
|
568
|
+
|
|
569
|
+
Contributions, issues and feature requests are welcome!
|
|
570
|
+
Feel free to check [issues](https://github.com/covalenthq/covalent-api-sdk-ts/issues) page.
|
|
571
|
+
|
|
572
|
+
## Show your support
|
|
573
|
+
|
|
574
|
+
Give a ⭐️ if this project helped you!
|
|
575
|
+
|
|
576
|
+
## License
|
|
577
|
+
|
|
578
|
+
This project is [MIT](./LICENSE) licensed.
|