@coinbase/cdp-sdk
Version:
SDK for interacting with the Coinbase Developer Platform Wallet API
57 lines (47 loc) • 2.54 kB
JavaScript
import { cdpApiClient } from "../../cdpApiClient.js";
/**
* Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs.
This endpoint provides direct SQL access to comprehensive blockchain data across supported networks.
Queries are executed against optimized data structures for high-performance analytics.
### Allowed Queries
- Standard SQL syntax (ClickHouse dialect)
- Read-only queries (SELECT statements)
- No DDL or DML operations
- No cartesian products
### Supported Tables
- `base.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more.
- `base.transactions` - Base mainnet transaction data including hash, block number, gas usage.
- `base.blocks` - Base mainnet block information.
- `base.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode).
- `base.transfers` - All event logs with event signature `Transfer(address,address,uint256)`. ERC-20, ERC-721, and ERC-1155 transfers are all included.
### Query Limits
- Maximum result set: 10,000 rows
- Query timeout: 30 seconds
- Maximum JOINs: 5
* @summary Run SQL Query
*/
export const runSQLQuery = (onchainDataQuery, options) => {
return cdpApiClient({
url: `/v2/data/query/run`,
method: "POST",
headers: { "Content-Type": "application/json" },
data: onchainDataQuery,
}, options);
};
/**
* 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, address, options) => {
return cdpApiClient({ 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.
**Note:** This endpoint provides <1 second freshness from chain tip, <500ms response latency for wallets with reasonable token history, and 99.9% uptime for production use.
* @summary List EVM token balances
*/
export const listDataTokenBalances = (network, address, params, options) => {
return cdpApiClient({ url: `/v2/data/evm/token-balances/${network}/${address}`, method: "GET", params }, options);
};
//# sourceMappingURL=onchain-data.js.map