@covalenthq/client-sdk 0.1.2 → 0.1.4
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 +44 -31
- package/dist/services/BalanceService.d.ts +390 -0
- package/dist/services/BalanceService.js +618 -0
- package/dist/services/BalanceService.js.map +1 -0
- package/dist/services/BaseService.d.ts +303 -0
- package/dist/services/BaseService.js +691 -0
- package/dist/services/BaseService.js.map +1 -0
- package/dist/services/Client.d.ts +22 -0
- package/dist/services/Client.js +26 -0
- package/dist/services/Client.js.map +1 -0
- package/dist/services/NftService.d.ts +428 -0
- package/dist/services/NftService.js +981 -0
- package/dist/services/NftService.js.map +1 -0
- package/dist/services/PricingService.d.ts +75 -0
- package/dist/services/PricingService.js +126 -0
- package/dist/services/PricingService.js.map +1 -0
- package/dist/services/SecurityService.d.ts +96 -0
- package/dist/services/SecurityService.js +122 -0
- package/dist/services/SecurityService.js.map +1 -0
- package/dist/services/TransactionService.d.ts +222 -0
- package/dist/services/TransactionService.js +433 -0
- package/dist/services/TransactionService.js.map +1 -0
- package/dist/services/XykService.d.ts +529 -0
- package/dist/services/XykService.js +1000 -0
- package/dist/services/XykService.js.map +1 -0
- package/dist/services/index.js.map +1 -0
- package/dist/util/ApiHelpers.d.ts +1 -0
- package/dist/util/ApiHelpers.js +15 -0
- package/dist/util/ApiHelpers.js.map +1 -0
- package/dist/util/backoff.d.ts +9 -0
- package/dist/util/backoff.js +25 -0
- package/dist/util/backoff.js.map +1 -0
- package/package.json +11 -3
- package/dist/ApprovalService.d.ts +0 -59
- package/dist/ApprovalService.js +0 -52
- package/dist/ApprovalService.js.map +0 -1
- package/dist/BalancesService.d.ts +0 -189
- package/dist/BalancesService.js +0 -231
- package/dist/BalancesService.js.map +0 -1
- package/dist/BaseService.d.ts +0 -169
- package/dist/BaseService.js +0 -276
- package/dist/BaseService.js.map +0 -1
- package/dist/Client.d.ts +0 -24
- package/dist/Client.js +0 -30
- package/dist/Client.js.map +0 -1
- package/dist/LogEventService.d.ts +0 -62
- package/dist/LogEventService.js +0 -75
- package/dist/LogEventService.js.map +0 -1
- package/dist/NameResolverService.d.ts +0 -33
- package/dist/NameResolverService.js +0 -52
- package/dist/NameResolverService.js.map +0 -1
- package/dist/NftService.d.ts +0 -271
- package/dist/NftService.js +0 -528
- package/dist/NftService.js.map +0 -1
- package/dist/PricingService.d.ts +0 -52
- package/dist/PricingService.js +0 -65
- package/dist/PricingService.js.map +0 -1
- package/dist/TransactionsService.d.ts +0 -126
- package/dist/TransactionsService.js +0 -230
- package/dist/TransactionsService.js.map +0 -1
- package/dist/XykService.d.ts +0 -383
- package/dist/XykService.js +0 -467
- package/dist/XykService.js.map +0 -1
- package/dist/index.js.map +0 -1
- /package/dist/{index.d.ts → services/index.d.ts} +0 -0
- /package/dist/{index.js → services/index.js} +0 -0
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ import { Client } from "@covalenthq/client-sdk";
|
|
|
25
25
|
|
|
26
26
|
const ApiServices = async () => {
|
|
27
27
|
const client = new Client("YOUR_API_KEY"); // Replace with your Covalent API key.
|
|
28
|
-
const resp = await client.
|
|
28
|
+
const resp = await client.BalanceService.getTokenBalancesForWalletAddress("eth-mainnet", "WALLET_ADDRESS"); // Example call, refer to API Docs for required paramaters or click into the method `getTokenBalancesForWalletAddress` to see the accepted parameter arguments
|
|
29
29
|
console.log(resp.data);
|
|
30
30
|
}
|
|
31
31
|
```
|
|
@@ -39,54 +39,43 @@ const ApiServices = async () => {
|
|
|
39
39
|
|
|
40
40
|
The Covalent SDK provides comprehensive support for all Class A, Class B, and Pricing endpoints grouped under various Services, offering a wide range of functionalities and capabilities:
|
|
41
41
|
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
42
|
+
- `SecurityService`: Access to the Covalent's getApprovals endpoint
|
|
43
|
+
- `BalanceService`: Access to the Covalent's balances endpoints
|
|
44
44
|
- `BaseServices`: Access to the Covalent's log events, chain, and block endpoints
|
|
45
|
-
- `LogEventService`: Access to the Covalent's get logs endpoint
|
|
46
|
-
- `NameResolverService`: Access to the Covalent's get resolved address for registered address endpoint
|
|
47
45
|
- `NftService`: Access to the Covalent's NFT endpoints
|
|
48
46
|
- `PricingService`: Access to the Covalent's get historical token prices endpoint
|
|
49
|
-
- `
|
|
47
|
+
- `TransactionService`: Access to the Covalent's transactions endpoints (with pagination)
|
|
50
48
|
- `XykService`: Access to the Covalent's Xy=k endpoints
|
|
51
49
|
|
|
52
|
-
###
|
|
50
|
+
### SecurityService
|
|
53
51
|
|
|
54
|
-
The `
|
|
52
|
+
The `SecurityService` class contains the getApprovals() endpoint, refer to the [getApprovals endpoint on our API docs](https://www.covalenthq.com/docs/api/security/get-token-approvals-for-address/).
|
|
55
53
|
|
|
56
54
|
- `getApprovals()`: Get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
|
|
57
55
|
|
|
58
|
-
###
|
|
56
|
+
### BalanceService
|
|
59
57
|
|
|
60
|
-
The `
|
|
58
|
+
The `BalanceService` class contains the balances endpoints. Listed below are the supported endpoints, also refer to our api docs under the Balances section in our class A endpoints.
|
|
61
59
|
|
|
62
|
-
- `
|
|
63
|
-
- `
|
|
64
|
-
- `
|
|
65
|
-
- `
|
|
60
|
+
- `getTokenBalancesForWalletAddress()`: Fetch the native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address. Response includes spot prices and other metadata.
|
|
61
|
+
- `getHistoricalTokenBalancesForWalletAddress()`: Fetch the historical native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
|
|
62
|
+
- `getHistoricalPortfolioForWalletAddress()`: Render a daily portfolio balance for an address broken down by the token. The timeframe is user-configurable, defaults to 30 days.
|
|
63
|
+
- `getErc20TransfersForWalletAddress()`: Render the transfer-in and transfer-out of a token along with historical prices from an address.
|
|
64
|
+
- `getTokenHoldersV2ForTokenAddress()`: Get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to latest). Useful for building pie charts of token holders.
|
|
66
65
|
|
|
67
66
|
### BaseServices
|
|
68
67
|
|
|
69
68
|
The `BaseServices` class contains the log events, chain, and block endpoints. Listed below are the supported endpoints, also refer to our api docs under the Base section in our class A endpoints.
|
|
70
69
|
|
|
71
70
|
- `getBlock()`: Fetch and render a single block for a block explorer.
|
|
71
|
+
- `getLogs()`: Get all the event logs of the latest block, or for a range of blocks. Includes sender contract metadata as well as decoded logs.
|
|
72
|
+
- `getResolvedAddress()`: Used to resolve ENS, RNS and Unstoppable Domains addresses.
|
|
72
73
|
- `getBlockHeights()`: Get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
|
|
73
74
|
- `getLogEventsByAddress()`: Get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
|
|
74
75
|
- `getLogEventsByTopicHash()`: 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.
|
|
75
76
|
- `getAllChains()`: Used to build internal dashboards for all supported chains on Covalent.
|
|
76
77
|
- `getAllChainStatus()`: Used to build internal status dashboards of all supported chains.
|
|
77
78
|
|
|
78
|
-
### LogEventService
|
|
79
|
-
|
|
80
|
-
The `LogEventService` class contains the getLogs() endpoint. Refer to the [getLogs endpoint on our API docs](https://www.covalenthq.com/docs/api/base/get-logs/).
|
|
81
|
-
|
|
82
|
-
- `getLogs()`: Get all the event logs of the latest block, or for a range of blocks. Includes sender contract metadata as well as decoded logs.
|
|
83
|
-
|
|
84
|
-
### NameResolverService
|
|
85
|
-
|
|
86
|
-
The `NameResolverService` class contains the getResolvedAddress() endpoint. Refer to the [getResolvedAddress endpoint on our API docs](https://www.covalenthq.com/docs/api/base/get-resolved-address-for-registered-address/).
|
|
87
|
-
|
|
88
|
-
- `getResolvedAddress()`: Used to resolve ENS, RNS and Unstoppable Domains addresses.
|
|
89
|
-
|
|
90
79
|
### NftService
|
|
91
80
|
|
|
92
81
|
The `NftService` class contains the NFT endpoints. Listed below are the supported endpoints, also refer to our api docs under the NFT section in our class A endpoints.
|
|
@@ -109,9 +98,9 @@ The `PricingService` class contains the getTokenPrices() endpoint. Refer to the
|
|
|
109
98
|
|
|
110
99
|
- `getTokenPrices()`: Get historic prices of a token between date ranges. Supports native tokens.
|
|
111
100
|
|
|
112
|
-
###
|
|
101
|
+
### TransactionService
|
|
113
102
|
|
|
114
|
-
The `
|
|
103
|
+
The `TransactionService` class contains the transactions endpoint. Listed below are the supported endpoints, also refer to our api docs under the Transactions section in our class A endpoints.
|
|
115
104
|
|
|
116
105
|
- `getRecentTransactionsForAddress()`: Fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
|
|
117
106
|
- `getTransaction()`: Fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.
|
|
@@ -136,14 +125,14 @@ The `XykService` class contains the Xy=k endpoints. Listed below are the support
|
|
|
136
125
|
|
|
137
126
|
### How pagination works
|
|
138
127
|
|
|
139
|
-
The Covalent getRecentTransactionsForAddress() endpoint is currently the only endpoint that supports pagination which return 100 results per page. To get the next page, it uses a link url that is grabbed from the previous call. Here's an example of how to paginate through all recent transactions on the ethereum blockchain for the demo's ENS address:
|
|
128
|
+
The Covalent `getRecentTransactionsForAddress()` endpoint is currently the only endpoint that supports pagination which return 100 results per page. To get the next page, it uses a link url that is grabbed from the previous call. Here's an example of how to paginate through all recent transactions on the ethereum blockchain for the demo's ENS address:
|
|
140
129
|
|
|
141
130
|
```ts
|
|
142
131
|
import { Client } from "@covalenthq/client-sdk";
|
|
143
132
|
|
|
144
133
|
const ApiServices = async () => {
|
|
145
134
|
const client = new Client("YOUR_API_KEY"); // Replace with your Covalent API key.
|
|
146
|
-
for await (const resp of client.
|
|
135
|
+
for await (const resp of client.TransactionService.getRecentTransactionsForAddress("eth-mainnet", "demo.eth")) {
|
|
147
136
|
console.log("resp", resp);
|
|
148
137
|
}
|
|
149
138
|
}
|
|
@@ -153,6 +142,30 @@ const ApiServices = async () => {
|
|
|
153
142
|
|
|
154
143
|
Each endpoint is equipped with an exponential backoff algorithm that exponentially extends the wait time between retries, making up to a `maximum of 5` retry attempts only.
|
|
155
144
|
|
|
145
|
+
### Error codes
|
|
146
|
+
Covalent uses standard HTTP response codes to indicate the success or failure of an API request. In general: codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, etc.). Codes in the 5xx range indicate an error with Covalent's servers (these are rare).
|
|
147
|
+
|
|
148
|
+
| Code | Description |
|
|
149
|
+
| ----------- | ----------- |
|
|
150
|
+
| 200 | OK Everything worked as expected. |
|
|
151
|
+
| 400 | Bad Request The request could not be accepted, usually due to a missing required parameter. |
|
|
152
|
+
| 401 | Unauthorized No valid API key was provided. |
|
|
153
|
+
| 404 | Not Found The request path does not exist. |
|
|
154
|
+
| 429 | Too Many Requests You are being rate-limited. Please see the rate limiting section for more information. |
|
|
155
|
+
| 500, 502, 503 | Server Errors Something went wrong on Covalent's servers. These are rare. |
|
|
156
|
+
|
|
157
|
+
## Tests
|
|
158
|
+
to run all tests, you need to input your api key first shown below
|
|
159
|
+
```
|
|
160
|
+
COVALENT_API_KEY=YOUR_KEY npm test
|
|
161
|
+
```
|
|
162
|
+
OR
|
|
163
|
+
|
|
164
|
+
you can run individual tests for each service, for example
|
|
165
|
+
```
|
|
166
|
+
COVALENT_API_KEY=YOUR_KEY npm test -- security-service.test.ts
|
|
167
|
+
```
|
|
168
|
+
|
|
156
169
|
## Documentation
|
|
157
170
|
|
|
158
|
-
The Covalent API SDK documentation is integrated within the source code through `tsdoc` comments. When utilizing an Integrated Development Environment (IDE), the SDK provides generated types and accompanying documentation for seamless reference and usage.
|
|
171
|
+
The Covalent API SDK documentation is integrated within the source code through `tsdoc` comments. When utilizing an Integrated Development Environment (IDE), the SDK provides generated types and accompanying documentation for seamless reference and usage.
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { Chains } from "./Client";
|
|
2
|
+
import { Quotes } from "./Client";
|
|
3
|
+
declare class BalancesResponse {
|
|
4
|
+
/** * The requested address. */
|
|
5
|
+
address: string;
|
|
6
|
+
/** * The requested chain ID eg: `1`. */
|
|
7
|
+
chain_id: number;
|
|
8
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
9
|
+
chain_name: string;
|
|
10
|
+
/** * The requested quote currency eg: `USD`. */
|
|
11
|
+
quote_currency: string;
|
|
12
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
13
|
+
updated_at: string;
|
|
14
|
+
/** * List of response items. */
|
|
15
|
+
items: BalanceItem[];
|
|
16
|
+
constructor(data: BalancesResponse);
|
|
17
|
+
}
|
|
18
|
+
declare class BalanceItem {
|
|
19
|
+
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
20
|
+
contract_decimals: number;
|
|
21
|
+
/** * The string returned by the `name()` method. */
|
|
22
|
+
contract_name: string;
|
|
23
|
+
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
|
|
24
|
+
contract_ticker_symbol: string;
|
|
25
|
+
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
26
|
+
contract_address: string;
|
|
27
|
+
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
28
|
+
supports_erc: string;
|
|
29
|
+
/** * The contract logo URL. */
|
|
30
|
+
logo_url: string;
|
|
31
|
+
/** * The timestamp when the token was transferred. */
|
|
32
|
+
last_transferred_at: string;
|
|
33
|
+
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
34
|
+
native_token: boolean;
|
|
35
|
+
/** * One of `cryptocurrency`, `stablecoin`, `nft` or `dust`. */
|
|
36
|
+
type: string;
|
|
37
|
+
/** * Denotes whether the token is suspected spam. */
|
|
38
|
+
is_spam: boolean;
|
|
39
|
+
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
40
|
+
balance: bigint | null;
|
|
41
|
+
/** * The exchange rate for the requested quote currency. */
|
|
42
|
+
quote_rate: number;
|
|
43
|
+
/** * The current balance converted to fiat in `quote-currency`. */
|
|
44
|
+
quote: number;
|
|
45
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
46
|
+
pretty_quote: string;
|
|
47
|
+
/** * NFT-specific data. */
|
|
48
|
+
nft_data: NftData[];
|
|
49
|
+
constructor(data: BalanceItem);
|
|
50
|
+
}
|
|
51
|
+
declare class NftData {
|
|
52
|
+
/** * The token's id. */
|
|
53
|
+
token_id: bigint | null;
|
|
54
|
+
token_url: string;
|
|
55
|
+
/** * The original minter. */
|
|
56
|
+
original_owner: string;
|
|
57
|
+
external_data: NftExternalData;
|
|
58
|
+
/** * If `true`, the asset data is available from the Covalent CDN. */
|
|
59
|
+
asset_cached: boolean;
|
|
60
|
+
/** * If `true`, the image data is available from the Covalent CDN. */
|
|
61
|
+
image_cached: boolean;
|
|
62
|
+
constructor(data: NftData);
|
|
63
|
+
}
|
|
64
|
+
declare class NftExternalData {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
asset_url: string;
|
|
68
|
+
asset_file_extension: string;
|
|
69
|
+
asset_mime_type: string;
|
|
70
|
+
asset_size_bytes: string;
|
|
71
|
+
image: string;
|
|
72
|
+
image_256: string;
|
|
73
|
+
image_512: string;
|
|
74
|
+
image_1024: string;
|
|
75
|
+
animation_url: string;
|
|
76
|
+
external_url: string;
|
|
77
|
+
attributes: NftCollectionAttribute[];
|
|
78
|
+
constructor(data: NftExternalData);
|
|
79
|
+
}
|
|
80
|
+
declare class NftCollectionAttribute {
|
|
81
|
+
trait_type: string;
|
|
82
|
+
value: string;
|
|
83
|
+
constructor(data: NftCollectionAttribute);
|
|
84
|
+
}
|
|
85
|
+
declare class PortfolioResponse {
|
|
86
|
+
/** * The requested address. */
|
|
87
|
+
address: string;
|
|
88
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
89
|
+
updated_at: string;
|
|
90
|
+
/** * The requested quote currency eg: `USD`. */
|
|
91
|
+
quote_currency: string;
|
|
92
|
+
/** * The requested chain ID eg: `1`. */
|
|
93
|
+
chain_id: number;
|
|
94
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
95
|
+
chain_name: string;
|
|
96
|
+
/** * List of response items. */
|
|
97
|
+
items: PortfolioItem[];
|
|
98
|
+
constructor(data: PortfolioResponse);
|
|
99
|
+
}
|
|
100
|
+
declare class PortfolioItem {
|
|
101
|
+
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
102
|
+
contract_address: string;
|
|
103
|
+
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
104
|
+
contract_decimals: number;
|
|
105
|
+
/** * The string returned by the `name()` method. */
|
|
106
|
+
contract_name: string;
|
|
107
|
+
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
|
|
108
|
+
contract_ticker_symbol: string;
|
|
109
|
+
/** * The contract logo URL. */
|
|
110
|
+
logo_url: string;
|
|
111
|
+
holdings: HoldingItem[];
|
|
112
|
+
constructor(data: PortfolioItem);
|
|
113
|
+
}
|
|
114
|
+
declare class HoldingItem {
|
|
115
|
+
/** * The exchange rate for the requested quote currency. */
|
|
116
|
+
quote_rate: number;
|
|
117
|
+
timestamp: string;
|
|
118
|
+
close: OhlcItem;
|
|
119
|
+
high: OhlcItem;
|
|
120
|
+
low: OhlcItem;
|
|
121
|
+
open: OhlcItem;
|
|
122
|
+
constructor(data: HoldingItem);
|
|
123
|
+
}
|
|
124
|
+
declare class OhlcItem {
|
|
125
|
+
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
126
|
+
balance: bigint | null;
|
|
127
|
+
quote: number;
|
|
128
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
129
|
+
pretty_quote: string;
|
|
130
|
+
constructor(data: OhlcItem);
|
|
131
|
+
}
|
|
132
|
+
declare class Erc20TransfersResponse {
|
|
133
|
+
/** * The requested address. */
|
|
134
|
+
address: string;
|
|
135
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
136
|
+
updated_at: string;
|
|
137
|
+
/** * The requested quote currency eg: `USD`. */
|
|
138
|
+
quote_currency: string;
|
|
139
|
+
/** * The requested chain ID eg: `1`. */
|
|
140
|
+
chain_id: number;
|
|
141
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
142
|
+
chain_name: string;
|
|
143
|
+
/** * List of response items. */
|
|
144
|
+
items: BlockTransactionWithContractTransfers[];
|
|
145
|
+
/** * Pagination metadata. */
|
|
146
|
+
pagination: Pagination;
|
|
147
|
+
constructor(data: Erc20TransfersResponse);
|
|
148
|
+
}
|
|
149
|
+
declare class BlockTransactionWithContractTransfers {
|
|
150
|
+
/** * The block signed timestamp in UTC. */
|
|
151
|
+
block_signed_at: string;
|
|
152
|
+
/** * The height of the block. */
|
|
153
|
+
block_height: number;
|
|
154
|
+
/** * The requested transaction hash. */
|
|
155
|
+
tx_hash: string;
|
|
156
|
+
/** * The offset is the position of the tx in the block. */
|
|
157
|
+
tx_offset: number;
|
|
158
|
+
successful: boolean;
|
|
159
|
+
from_address: string;
|
|
160
|
+
from_address_label: string;
|
|
161
|
+
to_address: string;
|
|
162
|
+
to_address_label: string;
|
|
163
|
+
/** * The value attached to this tx. */
|
|
164
|
+
value: bigint | null;
|
|
165
|
+
/** * The value attached in `quote-currency` to this tx. */
|
|
166
|
+
value_quote: number;
|
|
167
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
168
|
+
pretty_value_quote: string;
|
|
169
|
+
gas_offered: number;
|
|
170
|
+
gas_spent: number;
|
|
171
|
+
gas_price: number;
|
|
172
|
+
/** * The transaction's gas_price * gas_spent, denoted in wei. */
|
|
173
|
+
fees_paid: bigint | null;
|
|
174
|
+
/** * The gas spent in `quote-currency` denomination. */
|
|
175
|
+
gas_quote: number;
|
|
176
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
177
|
+
pretty_gas_quote: string;
|
|
178
|
+
/** * The native gas exchange rate for the requested `quote-currency`. */
|
|
179
|
+
gas_quote_rate: number;
|
|
180
|
+
transfers: TokenTransferItem[];
|
|
181
|
+
constructor(data: BlockTransactionWithContractTransfers);
|
|
182
|
+
}
|
|
183
|
+
declare class Pagination {
|
|
184
|
+
/** * True is there is another page. */
|
|
185
|
+
has_more: boolean;
|
|
186
|
+
/** * The requested page number. */
|
|
187
|
+
page_number: number;
|
|
188
|
+
/** * The requested number of items on the current page. */
|
|
189
|
+
page_size: number;
|
|
190
|
+
/** * The total number of items across all pages for this request. */
|
|
191
|
+
total_count: number;
|
|
192
|
+
constructor(data: Pagination);
|
|
193
|
+
}
|
|
194
|
+
declare class TokenTransferItem {
|
|
195
|
+
/** * The block signed timestamp in UTC. */
|
|
196
|
+
block_signed_at: string;
|
|
197
|
+
/** * The requested transaction hash. */
|
|
198
|
+
tx_hash: string;
|
|
199
|
+
from_address: string;
|
|
200
|
+
from_address_label: string;
|
|
201
|
+
to_address: string;
|
|
202
|
+
to_address_label: string;
|
|
203
|
+
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
204
|
+
contract_decimals: number;
|
|
205
|
+
/** * The string returned by the `name()` method. */
|
|
206
|
+
contract_name: string;
|
|
207
|
+
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
|
|
208
|
+
contract_ticker_symbol: string;
|
|
209
|
+
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
210
|
+
contract_address: string;
|
|
211
|
+
/** * The contract logo URL. */
|
|
212
|
+
logo_url: string;
|
|
213
|
+
transfer_type: string;
|
|
214
|
+
/** * The delta attached to this transfer. */
|
|
215
|
+
delta: bigint | null;
|
|
216
|
+
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
217
|
+
balance: bigint | null;
|
|
218
|
+
/** * The exchange rate for the requested quote currency. */
|
|
219
|
+
quote_rate: number;
|
|
220
|
+
delta_quote: number;
|
|
221
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
222
|
+
pretty_delta_quote: string;
|
|
223
|
+
balance_quote: number;
|
|
224
|
+
method_calls: MethodCallsForTransfers[];
|
|
225
|
+
constructor(data: TokenTransferItem);
|
|
226
|
+
}
|
|
227
|
+
declare class MethodCallsForTransfers {
|
|
228
|
+
sender_address: string;
|
|
229
|
+
method: string;
|
|
230
|
+
constructor(data: MethodCallsForTransfers);
|
|
231
|
+
}
|
|
232
|
+
declare class TokenHoldersResponse {
|
|
233
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
234
|
+
updated_at: string;
|
|
235
|
+
/** * The requested chain ID eg: `1`. */
|
|
236
|
+
chain_id: number;
|
|
237
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
238
|
+
chain_name: string;
|
|
239
|
+
/** * List of response items. */
|
|
240
|
+
items: TokenHolder[];
|
|
241
|
+
/** * Pagination metadata. */
|
|
242
|
+
pagination: Pagination;
|
|
243
|
+
constructor(data: TokenHoldersResponse);
|
|
244
|
+
}
|
|
245
|
+
declare class TokenHolder {
|
|
246
|
+
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
247
|
+
contract_decimals: number;
|
|
248
|
+
/** * The string returned by the `name()` method. */
|
|
249
|
+
contract_name: string;
|
|
250
|
+
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
|
|
251
|
+
contract_ticker_symbol: string;
|
|
252
|
+
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
253
|
+
contract_address: string;
|
|
254
|
+
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
255
|
+
supports_erc: string;
|
|
256
|
+
/** * The contract logo URL. */
|
|
257
|
+
logo_url: string;
|
|
258
|
+
/** * The requested address. */
|
|
259
|
+
address: string;
|
|
260
|
+
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
261
|
+
balance: bigint | null;
|
|
262
|
+
/** * Total supply of this token. */
|
|
263
|
+
total_supply: bigint | null;
|
|
264
|
+
/** * The height of the block. */
|
|
265
|
+
block_height: number;
|
|
266
|
+
constructor(data: TokenHolder);
|
|
267
|
+
}
|
|
268
|
+
declare class HistoricalBalancesResponse {
|
|
269
|
+
/** * The requested address. */
|
|
270
|
+
address: string;
|
|
271
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
272
|
+
updated_at: string;
|
|
273
|
+
/** * The requested quote currency eg: `USD`. */
|
|
274
|
+
quote_currency: string;
|
|
275
|
+
/** * The requested chain ID eg: `1`. */
|
|
276
|
+
chain_id: number;
|
|
277
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
278
|
+
chain_name: string;
|
|
279
|
+
/** * List of response items. */
|
|
280
|
+
items: HistoricalBalanceItem[];
|
|
281
|
+
constructor(data: HistoricalBalancesResponse);
|
|
282
|
+
}
|
|
283
|
+
declare class HistoricalBalanceItem {
|
|
284
|
+
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
285
|
+
contract_decimals: number;
|
|
286
|
+
/** * The string returned by the `name()` method. */
|
|
287
|
+
contract_name: string;
|
|
288
|
+
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
|
|
289
|
+
contract_ticker_symbol: string;
|
|
290
|
+
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
291
|
+
contract_address: string;
|
|
292
|
+
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
293
|
+
supports_erc: string;
|
|
294
|
+
/** * The contract logo URL. */
|
|
295
|
+
logo_url: string;
|
|
296
|
+
/** * The height of the block. */
|
|
297
|
+
block_height: number;
|
|
298
|
+
/** * The block height when the token was last transferred. */
|
|
299
|
+
last_transferred_block_height: number;
|
|
300
|
+
/** * The timestamp when the token was transferred. */
|
|
301
|
+
last_transferred_at: string;
|
|
302
|
+
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
303
|
+
native_token: boolean;
|
|
304
|
+
/** * One of `cryptocurrency`, `stablecoin`, `nft` or `dust`. */
|
|
305
|
+
type: string;
|
|
306
|
+
/** * Denotes whether the token is suspected spam. */
|
|
307
|
+
is_spam: boolean;
|
|
308
|
+
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
309
|
+
balance: bigint | null;
|
|
310
|
+
/** * The exchange rate for the requested quote currency. */
|
|
311
|
+
quote_rate: number;
|
|
312
|
+
/** * The current balance converted to fiat in `quote-currency`. */
|
|
313
|
+
quote: number;
|
|
314
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
315
|
+
pretty_quote: string;
|
|
316
|
+
/** * NFT-specific data. */
|
|
317
|
+
nft_data: NftData[];
|
|
318
|
+
constructor(data: HistoricalBalanceItem);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Balances APIs
|
|
322
|
+
*
|
|
323
|
+
*/
|
|
324
|
+
export declare class Response<T> {
|
|
325
|
+
data: T;
|
|
326
|
+
error: boolean;
|
|
327
|
+
error_code: number;
|
|
328
|
+
error_message: string;
|
|
329
|
+
}
|
|
330
|
+
export declare class BalanceService {
|
|
331
|
+
private apiKey;
|
|
332
|
+
constructor(apiKey: string);
|
|
333
|
+
/**
|
|
334
|
+
*
|
|
335
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
336
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
337
|
+
* @param {string} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
338
|
+
* @param {boolean} nft - If `true`, NFTs will be included in the response.
|
|
339
|
+
* @param {boolean} noNftFetch - If `true`, only NFTs that have been cached will be included in the response. Helpful for faster response times.
|
|
340
|
+
* @param {boolean} noSpam - If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
341
|
+
* @param {boolean} noNftAssetMetadata - If `true`, the response shape is limited to a list of collections and token ids, omitting metadata and asset information. Helpful for faster response times and wallets holding a large number of NFTs.
|
|
342
|
+
*
|
|
343
|
+
*/
|
|
344
|
+
getTokenBalancesForWalletAddress(chainName: Chains, walletAddress: string, quoteCurrency?: Quotes, nft?: boolean, noNftFetch?: boolean, noSpam?: boolean, noNftAssetMetadata?: boolean): Promise<Response<BalancesResponse>>;
|
|
345
|
+
/**
|
|
346
|
+
*
|
|
347
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
348
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
349
|
+
* @param {string} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
350
|
+
* @param {number} days - The number of days to return data for. Defaults to 30 days.
|
|
351
|
+
*
|
|
352
|
+
*/
|
|
353
|
+
getHistoricalPortfolioForWalletAddress(chainName: Chains, walletAddress: string, quoteCurrency?: Quotes, days?: number): Promise<Response<PortfolioResponse>>;
|
|
354
|
+
/**
|
|
355
|
+
*
|
|
356
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
357
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
358
|
+
* @param {string} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
359
|
+
* @param {string} contractAddress - The requested contract address.
|
|
360
|
+
* @param {number} startingBlock - The block height to start from, defaults to `0`.
|
|
361
|
+
* @param {number} endingBlock - The block height to end at, defaults to current block height.
|
|
362
|
+
*
|
|
363
|
+
*/
|
|
364
|
+
getErc20TransfersForWalletAddress(chainName: Chains, walletAddress: string, quoteCurrency?: Quotes, contractAddress?: string, startingBlock?: number, endingBlock?: number): Promise<Response<Erc20TransfersResponse>>;
|
|
365
|
+
/**
|
|
366
|
+
*
|
|
367
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
368
|
+
* @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
369
|
+
* @param {number} blockHeight - Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
370
|
+
* @param {number} pageSize - Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100.
|
|
371
|
+
* @param {number} pageNumber - 0-indexed page number to begin pagination.
|
|
372
|
+
*
|
|
373
|
+
*/
|
|
374
|
+
getTokenHoldersV2ForTokenAddress(chainName: Chains, tokenAddress: string, blockHeight?: number, pageSize?: number, pageNumber?: number): Promise<Response<TokenHoldersResponse>>;
|
|
375
|
+
/**
|
|
376
|
+
*
|
|
377
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
378
|
+
* @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
|
|
379
|
+
* @param {string} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
380
|
+
* @param {boolean} nft - If `true`, NFTs will be included in the response.
|
|
381
|
+
* @param {boolean} noNftFetch - If `true`, only NFTs that have been cached will be included in the response. Helpful for faster response times.
|
|
382
|
+
* @param {boolean} noSpam - If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
|
|
383
|
+
* @param {boolean} noNftAssetMetadata - If `true`, the response shape is limited to a list of collections and token ids, omitting metadata and asset information. Helpful for faster response times and wallets holding a large number of NFTs.
|
|
384
|
+
* @param {number} blockHeight - Ending block to define a block range. Omitting this parameter defaults to the latest block height.
|
|
385
|
+
* @param {number} date - Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date.
|
|
386
|
+
*
|
|
387
|
+
*/
|
|
388
|
+
getHistoricalTokenBalancesForWalletAddress(chainName: Chains, walletAddress: string, quoteCurrency?: Quotes, nft?: boolean, noNftFetch?: boolean, noSpam?: boolean, noNftAssetMetadata?: boolean, blockHeight?: number, date?: number): Promise<Response<HistoricalBalancesResponse>>;
|
|
389
|
+
}
|
|
390
|
+
export {};
|