@covalenthq/client-sdk
Version:
<div align="center"> <a href="https://goldrush.dev/" target="_blank" rel="noopener noreferrer"> <img alt="GoldRush TS SDK Logo" src="../../repo-static/ts-sdk-banner.png" style="max-width: 100%;"/> </a> </div>
433 lines (432 loc) • 19.7 kB
TypeScript
import { type ChainID, type ChainName, type ContractMetadata, type Explorer, type LogoUrls, type NftCollectionAttribute, type Nullable, type Pagination, type Quote } from "./Generic.types";
export type BalancesResponse = Nullable<{
/** * The requested address. */
address: string;
/** * The requested chain ID eg: `1`. */
chain_id: ChainID;
/** * The requested chain name eg: `eth-mainnet`. */
chain_name: ChainName;
/** * The requested quote currency eg: `USD`. */
quote_currency: Quote;
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
updated_at: Date;
/** * List of response items. */
items: BalanceItem[];
}>;
export type BalanceItem = Nullable<{
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
contract_decimals: number;
/** * The string returned by the `name()` method. */
contract_name: string;
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
contract_ticker_symbol: string;
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
contract_address: string;
/** * A display-friendly name for the contract. */
contract_display_name: string;
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
supports_erc: string[];
/** * The contract logo URL. */
logo_url: string;
/** * The contract logo URLs. */
logo_urls: LogoUrls;
/** * The timestamp when the token was transferred. */
last_transferred_at: Date;
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
native_token: boolean;
/** * One of `cryptocurrency`, `stablecoin`, `nft` or `dust`. */
type: string;
/** * Denotes whether the token is suspected spam. */
is_spam: boolean;
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance: bigint;
/** * The 24h asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance_24h: bigint;
/** * The exchange rate for the requested quote currency. */
quote_rate: number;
/** * The 24h exchange rate for the requested quote currency. */
quote_rate_24h: number;
/** * The current balance converted to fiat in `quote-currency`. */
quote: number;
/** * The 24h balance converted to fiat in `quote-currency`. */
quote_24h: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_quote: string;
/** * A prettier version of the 24h quote for rendering purposes. */
pretty_quote_24h: string;
/** * The protocol metadata. */
protocol_metadata: ProtocolMetadata;
/** * NFT-specific data. */
nft_data: BalanceNftData[];
}>;
export type ProtocolMetadata = Nullable<{
/** * The name of the protocol. */
protocol_name: string;
}>;
export type BalanceNftData = Nullable<{
/** * The token's id. */
token_id: bigint;
/** * The count of the number of NFTs with this ID. */
token_balance: bigint;
/** * External URL for additional metadata. */
token_url: string;
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
supports_erc: string[];
/** * The latest price value on chain of the token ID. */
token_price_wei: bigint;
/** * The latest quote_rate of the token ID denominated in unscaled ETH. */
token_quote_rate_eth: string;
/** * The address of the original owner of this NFT. */
original_owner: string;
external_data: NftExternalDataV1;
/** * The current owner of this NFT. */
owner: string;
/** * The address of the current owner of this NFT. */
owner_address: string;
/** * When set to true, this NFT has been Burned. */
burned: boolean;
}>;
export type NftExternalDataV1 = Nullable<{
name: string;
description: string;
image: string;
image_256: string;
image_512: string;
image_1024: string;
animation_url: string;
external_url: string;
attributes: NftCollectionAttribute[];
owner: string;
}>;
export type PortfolioResponse = Nullable<{
/** * The requested address. */
address: string;
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
updated_at: Date;
/** * The requested quote currency eg: `USD`. */
quote_currency: Quote;
/** * The requested chain ID eg: `1`. */
chain_id: ChainID;
/** * The requested chain name eg: `eth-mainnet`. */
chain_name: ChainName;
/** * List of response items. */
items: PortfolioItem[];
}>;
export type PortfolioItem = Nullable<{
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
contract_address: string;
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
contract_decimals: number;
/** * The string returned by the `name()` method. */
contract_name: string;
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
contract_ticker_symbol: string;
/** * The contract logo URL. */
logo_url: string;
holdings: HoldingItem[];
}>;
export type HoldingItem = Nullable<{
/** * The exchange rate for the requested quote currency. */
quote_rate: number;
timestamp: Date;
close: OhlcItem;
high: OhlcItem;
low: OhlcItem;
open: OhlcItem;
}>;
export type OhlcItem = Nullable<{
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance: bigint;
/** * The current balance converted to fiat in `quote-currency`. */
quote: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_quote: string;
}>;
export type Erc20TransfersResponse = Nullable<{
/** * The requested address. */
address: string;
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
updated_at: Date;
/** * The requested quote currency eg: `USD`. */
quote_currency: Quote;
/** * The requested chain ID eg: `1`. */
chain_id: ChainID;
/** * The requested chain name eg: `eth-mainnet`. */
chain_name: ChainName;
/** * List of response items. */
items: BlockTransactionWithContractTransfers[];
/** * Pagination metadata. */
pagination: Pagination;
}>;
export type BlockTransactionWithContractTransfers = Nullable<{
/** * The block signed timestamp in UTC. */
block_signed_at: Date;
/** * The height of the block. */
block_height: number;
/** * The hash of the block. Use it to remove transactions from re-org-ed blocks. */
block_hash: string;
/** * The requested transaction hash. */
tx_hash: string;
/** * The offset is the position of the tx in the block. */
tx_offset: number;
/** * Whether or not transaction is successful. */
successful: boolean;
/** * The address of the miner. */
miner_address: string;
/** * The sender's wallet address. */
from_address: string;
/** * The label of `from` address. */
from_address_label: string;
/** * The receiver's wallet address. */
to_address: string;
/** * The label of `to` address. */
to_address_label: string;
/** * The value attached to this tx. */
value: bigint;
/** * The value attached in `quote-currency` to this tx. */
value_quote: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_value_quote: string;
/** * The requested chain native gas token metadata. */
gas_metadata: ContractMetadata;
gas_offered: number;
/** * The gas spent for this tx. */
gas_spent: number;
/** * The gas price at the time of this tx. */
gas_price: number;
/** * The transaction's gas_price * gas_spent, denoted in wei. */
fees_paid: bigint;
/** * The gas spent in `quote-currency` denomination. */
gas_quote: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_gas_quote: string;
/** * The native gas exchange rate for the requested `quote-currency`. */
gas_quote_rate: number;
transfers: TokenTransferItem[];
}>;
export type TokenTransferItem = Nullable<{
/** * The block signed timestamp in UTC. */
block_signed_at: Date;
/** * The requested transaction hash. */
tx_hash: string;
/** * The sender's wallet address. */
from_address: string;
/** * The label of `from` address. */
from_address_label: string;
/** * The receiver's wallet address. */
to_address: string;
/** * The label of `to` address. */
to_address_label: string;
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
contract_decimals: number;
/** * The string returned by the `name()` method. */
contract_name: string;
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
contract_ticker_symbol: string;
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
contract_address: string;
/** * The contract logo URL. */
logo_url: string;
/** * Categorizes token transactions as either `transfer-in` or `transfer-out`, indicating whether tokens are being received or sent from an account. */
transfer_type: string;
/** * The delta attached to this transfer. */
delta: bigint;
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance: bigint;
/** * The exchange rate for the requested quote currency. */
quote_rate: number;
/** * The current delta converted to fiat in `quote-currency`. */
delta_quote: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_delta_quote: string;
/** * The current balance converted to fiat in `quote-currency`. */
balance_quote: number;
/** * Additional details on which transfer events were invoked. Defaults to `true`. */
method_calls: MethodCallsForTransfers[];
/** * The explorer links for this transaction. */
explorers: Explorer[];
}>;
export type MethodCallsForTransfers = Nullable<{
/** * The address of the sender. */
sender_address: string;
method: string;
}>;
export type TokenHoldersResponse = Nullable<{
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
updated_at: Date | null;
/** * The requested chain ID eg: `1`. */
chain_id: ChainID;
/** * The requested chain name eg: `eth-mainnet`. */
chain_name: ChainName;
/** * List of response items. */
items: TokenHolder[];
/** * Pagination metadata. */
pagination: Pagination;
}>;
export type TokenHolder = Nullable<{
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
contract_decimals: number;
/** * The string returned by the `name()` method. */
contract_name: string;
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
contract_ticker_symbol: string;
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
contract_address: string;
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
supports_erc: string[];
/** * The contract logo URL. */
logo_url: string;
/** * The requested address. */
address: string;
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance: bigint;
/** * Total supply of this token. */
total_supply: bigint;
/** * The height of the block. */
block_height: number;
}>;
export type HistoricalBalancesResponse = Nullable<{
/** * The requested address. */
address: string;
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
updated_at: Date;
/** * The requested quote currency eg: `USD`. */
quote_currency: Quote;
/** * The requested chain ID eg: `1`. */
chain_id: ChainID;
/** * The requested chain name eg: `eth-mainnet`. */
chain_name: ChainName;
/** * List of response items. */
items: HistoricalBalanceItem[];
}>;
export type HistoricalBalanceItem = Nullable<{
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
contract_decimals: number;
/** * The string returned by the `name()` method. */
contract_name: string;
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
contract_ticker_symbol: string;
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
contract_address: string;
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
supports_erc: string[];
/** * The contract logo URL. */
logo_url: string;
/** * The height of the block. */
block_height: number;
/** * The block height when the token was last transferred. */
last_transferred_block_height: number;
contract_display_name: string;
/** * The timestamp when the token was transferred. */
last_transferred_at: Date;
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
native_token: boolean;
/** * One of `cryptocurrency`, `stablecoin`, `nft` or `dust`. */
type: string;
/** * Denotes whether the token is suspected spam. */
is_spam: boolean;
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance: bigint;
/** * The exchange rate for the requested quote currency. */
quote_rate: number;
/** * The current balance converted to fiat in `quote-currency`. */
quote: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_quote: string;
/** * The protocol metadata. */
protocol_metadata: ProtocolMetadata;
/** * NFT-specific data. */
nft_data: BalanceNftData[];
}>;
export type TokenBalanceNativeResponse = Nullable<{
/** * The requested address. */
address: string;
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
updated_at: Date;
/** * The requested quote currency eg: `USD`. */
quote_currency: Quote;
/** * The requested chain ID eg: `1`. */
chain_id: ChainID;
/** * The requested chain name eg: `eth-mainnet`. */
chain_name: ChainName;
/** * List of response items. */
items: NativeBalanceItem[];
}>;
export type NativeBalanceItem = Nullable<{
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
contract_decimals: number;
/** * The string returned by the `name()` method. */
contract_name: string;
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
contract_ticker_symbol: string;
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
contract_address: string;
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
supports_erc: string[];
/** * The contract logo URL. */
logo_url: string;
/** * The height of the block. */
block_height: number;
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
balance: bigint;
/** * The exchange rate for the requested quote currency. */
quote_rate: number;
/** * The current balance converted to fiat in `quote-currency`. */
quote: number;
/** * A prettier version of the quote for rendering purposes. */
pretty_quote: string;
}>;
export type GetTokenBalancesForWalletAddressQueryParamOpts = Nullable<{
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
quoteCurrency?: Quote;
/** * If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`. */
noSpam?: boolean;
}>;
export type GetHistoricalPortfolioForWalletAddressQueryParamOpts = Nullable<{
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
quoteCurrency?: Quote;
/** * The number of days to return data for. Defaults to 30 days. */
days?: number;
}>;
export type GetErc20TransfersForWalletAddressQueryParamOpts = Nullable<{
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
quoteCurrency?: Quote;
/** * The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically. */
contractAddress: string;
/** * The block height to start from, defaults to `0`. */
startingBlock?: number;
/** * The block height to end at, defaults to current block height. */
endingBlock?: number;
/** * Number of items per page. Omitting this parameter defaults to 100. */
pageSize?: number;
/** * 0-indexed page number to begin pagination. */
pageNumber?: number;
}>;
export type GetTokenHoldersV2ForTokenAddressQueryParamOpts = Nullable<{
/** * Defaults to `false`. Set to `true` to bypass last snapshot and get the latest token holders list. */
noSnapshot?: boolean;
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
blockHeight?: number | string;
/** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
date?: string;
/** * Number of items per page. Note: Currently, only values of `100` and `1000` are supported. Omitting this parameter defaults to 100. */
pageSize?: number;
/** * 0-indexed page number to begin pagination. */
pageNumber?: number;
}>;
export type GetHistoricalTokenBalancesForWalletAddressQueryParamOpts = Nullable<{
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
quoteCurrency?: Quote;
/** * If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`. */
noSpam?: boolean;
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
blockHeight?: number | string;
/** * Ending date to define a block range (YYYY-MM-DD). Omitting this parameter defaults to the current date. */
date?: string;
}>;
export type GetNativeTokenBalanceQueryParamOpts = Nullable<{
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
quoteCurrency?: Quote;
/** * Ending block to define a block range. Omitting this parameter defaults to the latest block height. */
blockHeight?: number | string;
}>;