get_portfolio_balances
Retrieve token balances for wallet addresses across multiple blockchain networks to monitor portfolio holdings without price data.
Instructions
Get token balances for wallet addresses (faster, no prices/metadata, uses USER_ADDRESS from env if addresses not provided)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| addresses | No | Array of address and networks pairs (max 3 addresses, max 20 networks each). Optional - uses USER_ADDRESS from env if not provided | |
| networks | No | Network identifiers to use with USER_ADDRESS (e.g., 'eth-mainnet', 'base-mainnet'). Only used when addresses not provided. Defaults to ['eth-mainnet', 'base-mainnet'] | |
| includeNativeTokens | No | Include native tokens like ETH (optional, default: false) |
Implementation Reference
- src/services/agService.js:280-309 (helper)AgService helper that performs the actual API call to aggregator's /api/portfolio/balances endpoint to retrieve raw balance data.
async getPortfolioBalances(addresses, options = {}) { try { const requestBody = { addresses, includeNativeTokens: options.includeNativeTokens }; const response = await fetch(`${this.baseUrl}/api/portfolio/balances`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(requestBody) }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); if (!data.success) { throw new Error(data.error || 'Portfolio balances request failed'); } return data.data; } catch (error) { throw new Error(`Failed to get portfolio balances: ${error.message}`); } }