@quicknode/sdk 1.0.0-beta.0 → 1.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/README.md +2 -705
- package/cjs/index.js +494 -86
- package/esm/index.js +494 -87
- package/index.d.ts +2212 -272
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# QuickNode SDK
|
|
2
2
|
|
|
3
|
-
> :warning: **This is an beta release** This release is not production-ready yet and only meant as a technical preview. The API could break in subsequent beta releases until the 1.0.0 release is finalized.
|
|
4
|
-
|
|
5
3
|
A SDK from [QuickNode](https://www.quicknode.com/) making it easy for developers to interact with QuickNode's services.
|
|
6
4
|
|
|
7
5
|
QuickNode's SDK is a JavaScript and TypeScript framework-agnostic library that supports both CommonJS and ES module systems.
|
|
@@ -20,41 +18,6 @@ Currently the SDK makes it even easier to use the [QuickNode Graph API](https://
|
|
|
20
18
|
|
|
21
19
|
<br>
|
|
22
20
|
|
|
23
|
-
- [QuickNode SDK](#quicknode-sdk)
|
|
24
|
-
- [Getting Started](#getting-started)
|
|
25
|
-
- [Installation](#installation)
|
|
26
|
-
- [Quickstart](#quickstart)
|
|
27
|
-
- [API functions](#api-functions)
|
|
28
|
-
- [Configuration](#configuration)
|
|
29
|
-
- [Configuration Arguments](#configuration-arguments)
|
|
30
|
-
- [nfts.getByWallet](#nftsgetbywallet)
|
|
31
|
-
- [nfts.getTrendingCollections](#nftsgettrendingcollections)
|
|
32
|
-
- [nfts.getByContractAddress](#nftsgetbycontractaddress)
|
|
33
|
-
- [nfts.getNFTDetails](#nftsgetnftdetails)
|
|
34
|
-
- [nfts.getCollectionDetails](#nftsgetcollectiondetails)
|
|
35
|
-
- [tokens.getBalancesByWallet](#tokensgetbalancesbywallet)
|
|
36
|
-
- [contracts.getDetails](#contractsgetdetails)
|
|
37
|
-
- [transactions.getByWallet](#transactionsgetbywallet)
|
|
38
|
-
- [transactions.getAll](#transactionsgetall)
|
|
39
|
-
- [transactions.getByHash](#transactionsgetbyhash)
|
|
40
|
-
- [events.getByContract](#eventsgetbycontract)
|
|
41
|
-
- [events.getByNFTCollection](#eventsgetbynftcollection)
|
|
42
|
-
- [events.getByNFT](#eventsgetbynft)
|
|
43
|
-
- [events.getAll](#eventsgetall)
|
|
44
|
-
- [utils.getGasPrices](#utilsgetgasprices)
|
|
45
|
-
- [graphApiClient.query](#graphapiclientquery)
|
|
46
|
-
- [Filters](#filters)
|
|
47
|
-
- [Token Event Filters](#token-event-filters)
|
|
48
|
-
- [Pagination](#pagination)
|
|
49
|
-
- [Contributing corner](#contributing-corner)
|
|
50
|
-
- [Issues](#issues)
|
|
51
|
-
- [Development](#development)
|
|
52
|
-
- [Running tests](#running-tests)
|
|
53
|
-
- [Running linting](#running-linting)
|
|
54
|
-
- [Generate graphql codegen typings](#generate-graphql-codegen-typings)
|
|
55
|
-
|
|
56
|
-
<br>
|
|
57
|
-
|
|
58
21
|
## Getting Started
|
|
59
22
|
|
|
60
23
|
### Installation
|
|
@@ -83,675 +46,9 @@ Full example app implementation [here](https://github.com/quiknode-labs/qn-oss/t
|
|
|
83
46
|
|
|
84
47
|
<br>
|
|
85
48
|
|
|
86
|
-
##
|
|
87
|
-
|
|
88
|
-
These functions return data from the powerful [QuickNode Graph API](https://www.quicknode.com/graph-api), making it even easier to use.
|
|
89
|
-
|
|
90
|
-
<br>
|
|
91
|
-
|
|
92
|
-
### Configuration
|
|
93
|
-
|
|
94
|
-
Sign up for a [QuickNode](https://www.quicknode.com/) account to use the multi-chain [QuickNode GraphQL API](https://www.quicknode.com/graph-api) API key in the SDK.
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
import QuickNode from '@quicknode/sdk';
|
|
98
|
-
|
|
99
|
-
const qn = new QuickNode.API({
|
|
100
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
101
|
-
defaultChain: 'ethereum',
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
A `defaultChain` can be set to set the chain for all calls. Currently we support:
|
|
106
|
-
|
|
107
|
-
- `ethereum` Ethereum Mainnet
|
|
108
|
-
- `ethereumSepolia` Ethereum Sepolia
|
|
109
|
-
- `polygon` Polygon Mainnet
|
|
110
|
-
|
|
111
|
-
The `defaultChain` in the initializer can be overridden with the `chain` argument in functions.
|
|
112
|
-
|
|
113
|
-
If no `defaultChain` is passed into the initializer or a `chain` argument to a function,`ethereum` is used by default.
|
|
114
|
-
|
|
115
|
-
<br>
|
|
116
|
-
|
|
117
|
-
### Configuration Arguments
|
|
118
|
-
|
|
119
|
-
| Property | Values | Required | Description | Example |
|
|
120
|
-
| ------------ | ------ | -------- | ------------------------------------------------------------------- | -------- |
|
|
121
|
-
| graphApiKey | string | ❌ | The QuickNode GraphQL API Key | abcd1234 |
|
|
122
|
-
| defaultChain | string | ❌ | The default chain to use for all functions (defaults to `ethereum`) | polygon |
|
|
123
|
-
|
|
124
|
-
<br>
|
|
125
|
-
|
|
126
|
-
### nfts.getByWallet
|
|
127
|
-
|
|
128
|
-
Returns NFTs owned by a wallet
|
|
129
|
-
|
|
130
|
-
| Argument | Values | Required | Description | Example |
|
|
131
|
-
| -------- | ------ | -------- | --------------------------------------------------- | ---------------------------------- |
|
|
132
|
-
| address | string | ✅ | Wallet address or ENS domain | quicknode.eth |
|
|
133
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
134
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
135
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
136
|
-
| filter | object | ❌ | An object with the optional filters for the request | { contractAddressIn: ["0x00..."] } |
|
|
137
|
-
|
|
138
|
-
`filter` Parameters
|
|
139
|
-
|
|
140
|
-
| Argument | Values | Description | Example |
|
|
141
|
-
| ----------------- | ------ | ---------------------------------- | ---------------------------------------------- |
|
|
142
|
-
| contractAddressIn | Array | An array of NFT contract addresses | ["0x2106C00Ac7dA0A3430aE667879139E832307AeAa"] |
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
import QuickNode from '@quicknode/sdk';
|
|
146
|
-
|
|
147
|
-
const qn = new QuickNode.API({
|
|
148
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
qn.nfts
|
|
152
|
-
.getByWallet({
|
|
153
|
-
address: '0x51ABa267A6e8e1E76B44183a73E881D73A102F26',
|
|
154
|
-
first: 5,
|
|
155
|
-
})
|
|
156
|
-
.then((response) => console.log(response));
|
|
157
|
-
|
|
158
|
-
// can pass in ENS domain
|
|
159
|
-
qn.nfts
|
|
160
|
-
.getByWallet({
|
|
161
|
-
address: 'quicknode.eth',
|
|
162
|
-
first: 5,
|
|
163
|
-
})
|
|
164
|
-
.then((response) => console.log(response));
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
<br>
|
|
168
|
-
|
|
169
|
-
### nfts.getTrendingCollections
|
|
170
|
-
|
|
171
|
-
Returns trending NFT Collections
|
|
172
|
-
|
|
173
|
-
| Argument | Values | Required | Description | Example |
|
|
174
|
-
| -------- | ------ | -------- | ------------------------------- | --------------------------- |
|
|
175
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
176
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
177
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
import QuickNode from '@quicknode/sdk';
|
|
181
|
-
|
|
182
|
-
const qn = new QuickNode({
|
|
183
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
qn.nfts
|
|
187
|
-
.getTrendingCollections({
|
|
188
|
-
first: 5,
|
|
189
|
-
})
|
|
190
|
-
.then((response) => console.log(response));
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
<br>
|
|
194
|
-
|
|
195
|
-
### nfts.getByContractAddress
|
|
196
|
-
|
|
197
|
-
Returns NFTs by contract address. The response differs based on if they are an ERC721 or ERC1155 standard.
|
|
198
|
-
|
|
199
|
-
| Argument | Values | Required | Description | Example |
|
|
200
|
-
| --------------- | ------ | -------- | ------------------------------- | ------------------------------------------ |
|
|
201
|
-
| contractAddress | string | ✅ | NFT contract address | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
|
|
202
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
203
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
204
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
import QuickNode from '@quicknode/sdk';
|
|
208
|
-
|
|
209
|
-
const qn = new QuickNode.API({
|
|
210
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
qn.nfts
|
|
214
|
-
.getByContractAddress({
|
|
215
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
216
|
-
first: 5,
|
|
217
|
-
})
|
|
218
|
-
.then((response) => console.log(response));
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
<br>
|
|
222
|
-
|
|
223
|
-
### nfts.getNFTDetails
|
|
224
|
-
|
|
225
|
-
Returns the details for a specified NFT
|
|
226
|
-
|
|
227
|
-
| Argument | Values | Required | Description | Example |
|
|
228
|
-
| --------------- | ------ | -------- | -------------------- | ------------------------------------------ |
|
|
229
|
-
| contractAddress | string | ✅ | NFT contract address | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
|
|
230
|
-
| tokenId | string | ✅ | NFT Token ID | 1 |
|
|
231
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
232
|
-
|
|
233
|
-
```ts
|
|
234
|
-
import QuickNode from '@quicknode/sdk';
|
|
235
|
-
|
|
236
|
-
const qn = new QuickNode.API({
|
|
237
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
qn.nfts
|
|
241
|
-
.getNFTDetails({
|
|
242
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
243
|
-
tokenId: '1',
|
|
244
|
-
})
|
|
245
|
-
.then((response) => console.log(response));
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
<br>
|
|
249
|
-
|
|
250
|
-
### nfts.getCollectionDetails
|
|
251
|
-
|
|
252
|
-
Returns the details for an NFT Collection
|
|
253
|
-
|
|
254
|
-
| Argument | Values | Required | Description | Example |
|
|
255
|
-
| --------------- | ------ | -------- | -------------------- | ------------------------------------------ |
|
|
256
|
-
| contractAddress | string | ✅ | NFT contract address | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
|
|
257
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
258
|
-
|
|
259
|
-
```ts
|
|
260
|
-
import QuickNode from '@quicknode/sdk';
|
|
261
|
-
|
|
262
|
-
const qn = new QuickNode.API({
|
|
263
|
-
gqlApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
qn.nfts
|
|
267
|
-
.getCollectionDetails({
|
|
268
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
269
|
-
})
|
|
270
|
-
.then((response) => console.log(response));
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
<br>
|
|
274
|
-
|
|
275
|
-
### tokens.getBalancesByWallet
|
|
276
|
-
|
|
277
|
-
Returns ERC20 token balances for a wallet
|
|
278
|
-
|
|
279
|
-
| Argument | Values | Required | Description | Example |
|
|
280
|
-
| -------- | ------ | -------- | ------------------------------- | ------------------------------------------ |
|
|
281
|
-
| address | string | ✅ | Wallet address or ENS domain | 0x3C6aEFF92b4B35C2e1b196B57d0f8FFB56884A17 |
|
|
282
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
283
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
284
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
285
|
-
|
|
286
|
-
```ts
|
|
287
|
-
import QuickNode from '@quicknode/sdk';
|
|
288
|
-
|
|
289
|
-
const qn = new QuickNode.API({
|
|
290
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
qn.tokens
|
|
294
|
-
.getBalancesByWallet({
|
|
295
|
-
address: '0xd10e24685c7cdd3cd3baaa86b09c92be28c834b6',
|
|
296
|
-
first: 5,
|
|
297
|
-
})
|
|
298
|
-
.then((response) => console.log(response));
|
|
299
|
-
|
|
300
|
-
// Can pass in ENS domain
|
|
301
|
-
qn.tokens
|
|
302
|
-
.getBalancesByWallet({
|
|
303
|
-
address: 'quicknode.eth',
|
|
304
|
-
first: 5,
|
|
305
|
-
})
|
|
306
|
-
.then((response) => console.log(response));
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
<br>
|
|
310
|
-
|
|
311
|
-
### contracts.getDetails
|
|
312
|
-
|
|
313
|
-
Get the details and ABI for a contract address
|
|
314
|
-
|
|
315
|
-
| Argument | Values | Required | Description | Example |
|
|
316
|
-
| --------------- | ------ | -------- | ---------------- | ------------------------------------------ |
|
|
317
|
-
| contractAddress | string | ✅ | contract address | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
|
|
318
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
import QuickNode, { gql } from '@quicknode/sdk';
|
|
322
|
-
|
|
323
|
-
const qn = new QuickNode.API({
|
|
324
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
qn.contracts
|
|
328
|
-
.getDetails({
|
|
329
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
330
|
-
})
|
|
331
|
-
.then((response) => console.log(response));
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
<br>
|
|
335
|
-
|
|
336
|
-
### transactions.getByWallet
|
|
337
|
-
|
|
338
|
-
Returns transactions for a wallet
|
|
339
|
-
|
|
340
|
-
| Argument | Values | Required | Description | Example |
|
|
341
|
-
| -------- | ------ | -------- | ------------------------------- | ------------------------------------------ |
|
|
342
|
-
| address | string | ✅ | Wallet address or ENS domain | 0x3C6aEFF92b4B35C2e1b196B57d0f8FFB56884A17 |
|
|
343
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
344
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
345
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
346
|
-
|
|
347
|
-
```ts
|
|
348
|
-
import QuickNode from '@quicknode/sdk';
|
|
349
|
-
|
|
350
|
-
const qn = new QuickNode.API({
|
|
351
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
qn.transactions
|
|
355
|
-
.getByWallet({
|
|
356
|
-
address: '0xd10e24685c7cdd3cd3baaa86b09c92be28c834b6',
|
|
357
|
-
first: 5,
|
|
358
|
-
})
|
|
359
|
-
.then((response) => console.log(response));
|
|
49
|
+
## Documentation
|
|
360
50
|
|
|
361
|
-
|
|
362
|
-
qn.transactions
|
|
363
|
-
.getByWallet({
|
|
364
|
-
address: 'quicknode.eth',
|
|
365
|
-
first: 5,
|
|
366
|
-
})
|
|
367
|
-
.then((response) => console.log(response));
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
<br>
|
|
371
|
-
|
|
372
|
-
### transactions.getAll
|
|
373
|
-
|
|
374
|
-
Returns transactions filtered by search parameters
|
|
375
|
-
|
|
376
|
-
| Argument | Values | Required | Description | Example |
|
|
377
|
-
| -------- | ------ | -------- | --------------------------------------------------- | ------------------------------- |
|
|
378
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
379
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
380
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
381
|
-
| filter | object | ✅ | An object with the optional filters for the request | { blockNumber: { eq: 123456 } } |
|
|
382
|
-
|
|
383
|
-
`filter` Parameters
|
|
384
|
-
|
|
385
|
-
| Argument | Values | Description | Example |
|
|
386
|
-
| ----------- | ------ | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------- |
|
|
387
|
-
| fromAddress | string | Filter transactions sent from address | fromAddress: "0xD10E24685c7CDD3cd3BaAA86b09C92Be28c834B6" |
|
|
388
|
-
| toAddress | string | Filter transactions sent to address | toAddress: "0xD10E24685c7CDD3cd3BaAA86b09C92Be28c834B6" |
|
|
389
|
-
| blockNumber | object | An object with any combination of `eq`, `gt`, `gte`, `in`, `lt`, or `lte` | { lt: 17343891, gt: 17343881 } |
|
|
390
|
-
| timestamp | object | An object with any combination of `eq`, `gt`, `gte`, `in`, `lt`, or `lte` with a valid timestamp | { lt: "2022-12-03T10:15:30Z" } |
|
|
391
|
-
|
|
392
|
-
_timestamp can be a date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the date-time format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar._
|
|
393
|
-
|
|
394
|
-
```ts
|
|
395
|
-
import QuickNode from '@quicknode/sdk';
|
|
396
|
-
|
|
397
|
-
const qn = new QuickNode.API({
|
|
398
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// Use the filters
|
|
402
|
-
qn.transactions
|
|
403
|
-
.getAll({
|
|
404
|
-
filter: {
|
|
405
|
-
blockNumber: {
|
|
406
|
-
eq: 17372310,
|
|
407
|
-
},
|
|
408
|
-
fromAddress: '0x41407a3c41da7970d30a0343cda8b9db70c145fb',
|
|
409
|
-
},
|
|
410
|
-
})
|
|
411
|
-
.then((response) => console.log(response));
|
|
412
|
-
|
|
413
|
-
// Filters can be left blank to get the latest data
|
|
414
|
-
qn.transactions.getAll({ filter: {}, first: 5 }).then((response) => console.log(response));
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
<br>
|
|
418
|
-
|
|
419
|
-
### transactions.getByHash
|
|
420
|
-
|
|
421
|
-
Returns transaction information by transaction hash
|
|
422
|
-
|
|
423
|
-
| Argument | Values | Required | Description | Example |
|
|
424
|
-
| -------- | ------ | -------- | ----------------------- | ------------------------------------------------------------------ |
|
|
425
|
-
| hash | string | ✅ | Hash of the transaction | 0x1aa26d1d542b414dd2e2d1aa6f8d8e128e2a45bc4a04c24232207221914389bf |
|
|
426
|
-
|
|
427
|
-
```ts
|
|
428
|
-
import QuickNode from '@quicknode/sdk';
|
|
429
|
-
|
|
430
|
-
const qn = new QuickNode.API({
|
|
431
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
qn.transactions
|
|
435
|
-
.getByHash({
|
|
436
|
-
hash: '0x1aa26d1d542b414dd2e2d1aa6f8d8e128e2a45bc4a04c24232207221914389bf',
|
|
437
|
-
})
|
|
438
|
-
.then((response) => console.log(response));
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
<br>
|
|
442
|
-
|
|
443
|
-
### events.getByContract
|
|
444
|
-
|
|
445
|
-
Returns events by contract address
|
|
446
|
-
|
|
447
|
-
| Argument | Values | Required | Description | Example |
|
|
448
|
-
| -------- | ------ | -------- | --------------------------------------------------- | ------------------------------- |
|
|
449
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
450
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
451
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
452
|
-
| filter | object | ❌ | An object with the optional filters for the request | { blockNumber: { eq: 123456 } } |
|
|
453
|
-
|
|
454
|
-
`filter` Parameters
|
|
455
|
-
|
|
456
|
-
Please see the [Token Event Filters section](#token-event-filters) for all options
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
import QuickNode from '@quicknode/sdk';
|
|
460
|
-
|
|
461
|
-
const qn = new QuickNode.API({
|
|
462
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
qn.events
|
|
466
|
-
.getByContract({
|
|
467
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
468
|
-
})
|
|
469
|
-
.then((response) => console.log(response));
|
|
470
|
-
|
|
471
|
-
// Using filters
|
|
472
|
-
qn.events
|
|
473
|
-
.getByContract({
|
|
474
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
475
|
-
filter: {
|
|
476
|
-
fromAddress: {
|
|
477
|
-
eq: '0x10fa1c188eca954419a85112f975155f717ad8ea',
|
|
478
|
-
},
|
|
479
|
-
type: {
|
|
480
|
-
in: ['TRANSFER'],
|
|
481
|
-
},
|
|
482
|
-
}
|
|
483
|
-
})
|
|
484
|
-
.then((response) => console.log(response));
|
|
485
|
-
`
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
<br>
|
|
489
|
-
|
|
490
|
-
### events.getByNFTCollection
|
|
491
|
-
|
|
492
|
-
Returns the events for an NFT Collection
|
|
493
|
-
|
|
494
|
-
| Argument | Values | Required | Description | Example |
|
|
495
|
-
| --------------- | ------ | -------- | --------------------------------------------------- | ------------------------------------------ |
|
|
496
|
-
| contractAddress | string | ✅ | NFT contract address | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
|
|
497
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
498
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
499
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
500
|
-
| filter | object | ❌ | An object with the optional filters for the request | { blockNumber: { eq: 123456 } } |
|
|
501
|
-
|
|
502
|
-
`filter` Parameters
|
|
503
|
-
|
|
504
|
-
Please see the [Token Event Filters section](#token-event-filters) for all options
|
|
505
|
-
|
|
506
|
-
```ts
|
|
507
|
-
import QuickNode from '@quicknode/sdk';
|
|
508
|
-
|
|
509
|
-
const qn = new QuickNode.API({
|
|
510
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
qn.events
|
|
514
|
-
.getByNFTCollection({
|
|
515
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
516
|
-
first: 5,
|
|
517
|
-
})
|
|
518
|
-
.then((response) => console.log(response));
|
|
519
|
-
|
|
520
|
-
// Can pass in filters
|
|
521
|
-
qn.events
|
|
522
|
-
.getByNftCollection({
|
|
523
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
524
|
-
first: 5,
|
|
525
|
-
filter: {
|
|
526
|
-
type: {
|
|
527
|
-
eq: 'TRANSFER',
|
|
528
|
-
},
|
|
529
|
-
},
|
|
530
|
-
})
|
|
531
|
-
.then((response) => console.log(response));
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
<br>
|
|
535
|
-
|
|
536
|
-
### events.getByNFT
|
|
537
|
-
|
|
538
|
-
Returns the events for a specific NFT
|
|
539
|
-
|
|
540
|
-
| Argument | Values | Required | Description | Example |
|
|
541
|
-
| --------------- | ------ | -------- | --------------------------------------------------- | ------------------------------------------ |
|
|
542
|
-
| contractAddress | string | ✅ | NFT contract address | 0x2106C00Ac7dA0A3430aE667879139E832307AeAa |
|
|
543
|
-
| tokenId | string | ✅ | NFT Token ID | 1 |
|
|
544
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
545
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
546
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
547
|
-
| filter | object | ❌ | An object with the optional filters for the request | { blockNumber: { eq: 123456 } } |
|
|
548
|
-
|
|
549
|
-
`filter` Parameters
|
|
550
|
-
|
|
551
|
-
Please see the [Token Event Filters section](#token-event-filters) for all options
|
|
552
|
-
|
|
553
|
-
```ts
|
|
554
|
-
import QuickNode from '@quicknode/sdk';
|
|
555
|
-
|
|
556
|
-
const qn = new QuickNode.API({
|
|
557
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
qn.events
|
|
561
|
-
.getByNFT({
|
|
562
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
563
|
-
tokenId: '1',
|
|
564
|
-
})
|
|
565
|
-
.then((response) => console.log(response));
|
|
566
|
-
|
|
567
|
-
qn.events
|
|
568
|
-
.getByNFT({
|
|
569
|
-
contractAddress: '0x2106C00Ac7dA0A3430aE667879139E832307AeAa',
|
|
570
|
-
tokenId: '1',
|
|
571
|
-
filter: {
|
|
572
|
-
type: {
|
|
573
|
-
eq: 'TRANSFER',
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
})
|
|
577
|
-
.then((response) => console.log(response));
|
|
578
|
-
```
|
|
579
|
-
|
|
580
|
-
<br>
|
|
581
|
-
|
|
582
|
-
### events.getAll
|
|
583
|
-
|
|
584
|
-
Returns events filtered by search parameters
|
|
585
|
-
|
|
586
|
-
| Argument | Values | Required | Description | Example |
|
|
587
|
-
| -------- | ------ | -------- | --------------------------------------------------- | ------------------------------- |
|
|
588
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
589
|
-
| first | number | ❌ | Number of results to return | 10 |
|
|
590
|
-
| after | string | ❌ | Return results after end cursor | YXJyYXljb25uZWN0aW9uOjUwNQ= |
|
|
591
|
-
| filter | object | ❌ | An object with the optional filters for the request | { blockNumber: { eq: 123456 } } |
|
|
592
|
-
|
|
593
|
-
`filter` Parameters
|
|
594
|
-
|
|
595
|
-
Please see the [Token Event Filters section](#token-event-filters) for all options
|
|
596
|
-
|
|
597
|
-
```ts
|
|
598
|
-
import QuickNode from '@quicknode/sdk';
|
|
599
|
-
|
|
600
|
-
const qn = new QuickNode.API({
|
|
601
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
// Use filters to get specific events
|
|
605
|
-
qn.events
|
|
606
|
-
.getAll({
|
|
607
|
-
first: 2,
|
|
608
|
-
filter: {
|
|
609
|
-
blockNumber: {
|
|
610
|
-
eq: 17414768,
|
|
611
|
-
},
|
|
612
|
-
toAddress: {
|
|
613
|
-
eq: '0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b',
|
|
614
|
-
},
|
|
615
|
-
},
|
|
616
|
-
})
|
|
617
|
-
.then((response) => console.log(response));
|
|
618
|
-
|
|
619
|
-
// Filters can be left blank to get the latest data
|
|
620
|
-
qn.events.getAll({}).then((response) => console.log(response));
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
<br>
|
|
624
|
-
|
|
625
|
-
### utils.getGasPrices
|
|
626
|
-
|
|
627
|
-
Returns historical gas prices by block number. Defaults to returning values in wei.
|
|
628
|
-
|
|
629
|
-
| Argument | Values | Required | Description | Example |
|
|
630
|
-
| ------------ | ------- | -------- | --------------------------------------------------- | --------------------------------- |
|
|
631
|
-
| chain | string | ❌ | Blockchain name | polygon |
|
|
632
|
-
| returnInGwei | boolean | ❌ | Return gas values in Gwei | true |
|
|
633
|
-
| filter | object | ❌ | An object with the optional filters for the request | { blockNumber: { eq: 17343891 } } |
|
|
634
|
-
|
|
635
|
-
`filter` Parameters
|
|
636
|
-
|
|
637
|
-
| Argument | Values | Description | Example |
|
|
638
|
-
| ----------- | ------ | ------------------------------------------------------------------------- | ------------------------------ |
|
|
639
|
-
| blockNumber | object | An object with any combination of `eq`, `gt`, `gte`, `in`, `lt`, or `lte` | { lt: 17343891, gt: 17343881 } |
|
|
640
|
-
|
|
641
|
-
```ts
|
|
642
|
-
import QuickNode from '@quicknode/sdk';
|
|
643
|
-
|
|
644
|
-
const qn = new QuickNode.API({
|
|
645
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
// Get the latest data
|
|
649
|
-
qn.utils.getGasPrices({}).then((response) => console.log(response));
|
|
650
|
-
|
|
651
|
-
// Get filtered data
|
|
652
|
-
qn.utils
|
|
653
|
-
.getGasPrices({
|
|
654
|
-
filter: {
|
|
655
|
-
blockNumber: {
|
|
656
|
-
eq: 17343891,
|
|
657
|
-
},
|
|
658
|
-
},
|
|
659
|
-
})
|
|
660
|
-
.then((response) => console.log(response));
|
|
661
|
-
```
|
|
662
|
-
|
|
663
|
-
<br>
|
|
664
|
-
|
|
665
|
-
### graphApiClient.query
|
|
666
|
-
|
|
667
|
-
A way to send GraphQL queries directly to the [QuickNode GraphQL API](https://www.quicknode.com/graph-api). `graphApiClient` is an [Urql client](https://formidable.com/open-source/urql/docs/api/core/#client) instance configured to use QuickNode's Graph API. For more information about the query structure, see the [Graph API documentation](https://docs.quicknode.com/docs/graphql/getting-started/)
|
|
668
|
-
|
|
669
|
-
```ts
|
|
670
|
-
import QuickNode, { gql } from '@quicknode/sdk';
|
|
671
|
-
|
|
672
|
-
const qn = new QuickNode.API({
|
|
673
|
-
graphApiKey: 'my-api-key', // which is obtained by signing up on https://www.quicknode.com/signup
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
const query = gql`
|
|
677
|
-
query ($contractAddress: String!) {
|
|
678
|
-
ethereum {
|
|
679
|
-
collection(contractAddress: $contractAddress) {
|
|
680
|
-
address
|
|
681
|
-
name
|
|
682
|
-
symbol
|
|
683
|
-
totalSupply
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
`;
|
|
688
|
-
const variables = {
|
|
689
|
-
contractAddress: '0x2106c00ac7da0a3430ae667879139e832307aeaa',
|
|
690
|
-
};
|
|
691
|
-
|
|
692
|
-
qn.graphApiClient.query({ query, variables }).then(({ data }) => console.log(data));
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
<br>
|
|
696
|
-
|
|
697
|
-
## Filters
|
|
698
|
-
|
|
699
|
-
Some filters are shared between queries
|
|
700
|
-
|
|
701
|
-
<br>
|
|
702
|
-
|
|
703
|
-
### Token Event Filters
|
|
704
|
-
|
|
705
|
-
| Argument | Values | Description | Example |
|
|
706
|
-
| ---------------- | ------ | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
707
|
-
| blockNumber | object | An object with any combination of `eq`, `gt`, `gte`, `in`, `lt`, or `lte` | { lt: 17343891, gt: 17343881 } |
|
|
708
|
-
| contractAddress | object | A contract address with `eq`, `in`, or `notIn` | { eq: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984" } |
|
|
709
|
-
| contractStandard | object | A valid contract standard `ERC20`, `ERC721`, `ERC1155` with `eq`, `in`, or `notIn` | { eq: "ERC20" } |
|
|
710
|
-
| fromAddress | object | Filter events sent from address with `eq`, `in`, or `notIn` | { eq: "0xD10E24685c7CDD3cd3BaAA86b09C92Be28c834B6" } |
|
|
711
|
-
| marketplace | object | `BLUR`, `CRYPTOPUNKS`, `LOOKSRARE`, `NIFTY_GATEWAY`, `OPENSEA`, `SEAPORT`, `X2Y2`, `ZEROX` with with `eq`, `in`, or `notIn` | { eq: "OPENSEA" } |
|
|
712
|
-
| timestamp | object | An object with any combination of `eq`, `gt`, `gte`, `in`, `lt`, or `lte` with a valid timestamp | { lt: "2022-12-03T10:15:30Z" } |
|
|
713
|
-
| toAddress | object | Filter events sent to address with `eq`, `in`, or `notIn` | { eq: "0xD10E24685c7CDD3cd3BaAA86b09C92Be28c834B6" } |
|
|
714
|
-
| transactionHash | object | A transaction hash with with `eq`, `in`, or `notIn` | { eq: "0xdd652cfd936f7a22ab217a69c1f4356a6d15a4c8d61e30d87a4cd8abca30046f" } |
|
|
715
|
-
| type | object | `TRANSFER`, `MINT`, `SALE`, `SWAP`, or `BURN` with `eq`, `in`, or `notIn` | { in: ["TRANSFER", "MINT"] } |
|
|
716
|
-
| walletAddress | object | A valid wallet address with `eq`, `in`, or `notIn` | { eq: "0xD10E24685c7CDD3cd3BaAA86b09C92Be28c834B6" } |
|
|
717
|
-
|
|
718
|
-
_timestamp can be a date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the date-time format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar._
|
|
719
|
-
|
|
720
|
-
<br>
|
|
721
|
-
|
|
722
|
-
## Pagination
|
|
723
|
-
|
|
724
|
-
For functions that support pagination, use the `first` property to specify the amount of results to return.
|
|
725
|
-
|
|
726
|
-
The returned `data.tokensPageInfo.endCursor` property in the response can be used to access subsequent results. This value can be passed in to the `after` property and will return the results after that `endCursor`.
|
|
727
|
-
|
|
728
|
-
`hasNextPage` can be used to determine the end of the results, where it will be `false`.
|
|
729
|
-
|
|
730
|
-
For example, if a response contains:
|
|
731
|
-
|
|
732
|
-
```json
|
|
733
|
-
{
|
|
734
|
-
"results": [],
|
|
735
|
-
"pageInfo": {
|
|
736
|
-
"endCursor": "T2Zmc2V0Q29ubmVjdGlvbjox",
|
|
737
|
-
"hasNextPage": true,
|
|
738
|
-
"hasPreviousPage": false,
|
|
739
|
-
"startCursor": "T2Zmc2V0Q29ubmVjdGlvbjow"
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
```
|
|
743
|
-
|
|
744
|
-
calling the following will get the next page of results
|
|
745
|
-
|
|
746
|
-
```typescript
|
|
747
|
-
qn.nfts.getByWallet({
|
|
748
|
-
address: 'quicknode.eth',
|
|
749
|
-
first: 5,
|
|
750
|
-
after: 'T2Zmc2V0Q29ubmVjdGlvbjox',
|
|
751
|
-
});
|
|
752
|
-
```
|
|
753
|
-
|
|
754
|
-
<br>
|
|
51
|
+
Please see [the official QuickNode SDK documentation](https://www.quicknode.com/docs/quicknode-sdk/getting-started) for the full documentation of SDK functions.
|
|
755
52
|
|
|
756
53
|
## Contributing corner
|
|
757
54
|
|