UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

64 lines (57 loc) • 2.32 kB
/** * Generated by orval v7.21.0 🍺 * Do not edit manually. * Coinbase Developer Platform APIs * The Coinbase Developer Platform APIs - leading the world's transition onchain. * OpenAPI spec version: 2.0.0 */ import type { AccountTokenAddressesResponse, ListDataTokenBalances200, ListDataTokenBalancesParams, ListEvmTokenBalancesNetwork, } from "../coinbaseDeveloperPlatformAPIs.schemas.js"; import { cdpApiClient } from "../../cdpApiClient.js"; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; /** * Retrieve all ERC-20 token contract addresses that an account has ever received tokens from. Analyzes transaction history to discover token interactions. * @summary List token addresses for account */ export const listTokensForAccount = ( network: "base" | "base-sepolia", address: string, options?: SecondParameter<typeof cdpApiClient<AccountTokenAddressesResponse>>, ) => { return cdpApiClient<AccountTokenAddressesResponse>( { url: `/v2/data/evm/token-ownership/${network}/${address}`, method: "GET" }, options, ); }; /** * Lists the token balances of an EVM address on a given network. The balances include ERC-20 tokens and the native gas token (usually ETH). The response is paginated, and by default, returns 20 balances per page. Calls to the `base` and `base-sepolia` networks offer: * 99.5% < 2 second freshness from chain tip for new tokens on an address. * 99.5% < 2 second freshness from chain tip for balance data. Calls to the `ethereum` network offer: * 99% < 30 second freshness from chain tip for new tokens on an address. * 99% < 2 second freshness from chain tip for balance data. * @summary List EVM token balances */ export const listDataTokenBalances = ( network: ListEvmTokenBalancesNetwork, address: string, params?: ListDataTokenBalancesParams, options?: SecondParameter<typeof cdpApiClient<ListDataTokenBalances200>>, ) => { return cdpApiClient<ListDataTokenBalances200>( { url: `/v2/data/evm/token-balances/${network}/${address}`, method: "GET", params }, options, ); }; export type ListTokensForAccountResult = NonNullable< Awaited<ReturnType<typeof listTokensForAccount>> >; export type ListDataTokenBalancesResult = NonNullable< Awaited<ReturnType<typeof listDataTokenBalances>> >;