|
| 1 | +--- |
| 2 | +title: 'Get Agent Funds' |
| 3 | +api: 'POST /user/{appId}/agent-funds' |
| 4 | +--- |
| 5 | + |
| 6 | +Retrieve the token balances held by the user's agent smart account. This endpoint wraps the [Alchemy Portfolio API](https://www.alchemy.com/docs/data/portfolio-apis/portfolio-api-endpoints/portfolio-api-endpoints/get-tokens-by-address) to fetch token data across multiple networks. |
| 7 | + |
| 8 | +## Request |
| 9 | + |
| 10 | +<ParamField path="appId" type="integer" required> |
| 11 | + The unique identifier of the app |
| 12 | +</ParamField> |
| 13 | + |
| 14 | +<ParamField body="userControllerAddress" type="string" required> |
| 15 | + The Ethereum address of the user's wallet |
| 16 | +</ParamField> |
| 17 | + |
| 18 | +<ParamField body="networks" type="string[]" required> |
| 19 | + Networks to query for token balances (e.g., `["base-mainnet", "base-sepolia"]`) |
| 20 | +</ParamField> |
| 21 | + |
| 22 | +## Response |
| 23 | + |
| 24 | +<ResponseField name="agentAddress" type="string"> |
| 25 | + The derived agent smart account address |
| 26 | +</ResponseField> |
| 27 | + |
| 28 | +<ResponseField name="tokens" type="array"> |
| 29 | + List of tokens held by the agent |
| 30 | + |
| 31 | + <Expandable title="Token object properties"> |
| 32 | + <ResponseField name="address" type="string"> |
| 33 | + Wallet address that holds the token |
| 34 | + </ResponseField> |
| 35 | + <ResponseField name="network" type="string"> |
| 36 | + Network identifier (e.g., `base-mainnet`) |
| 37 | + </ResponseField> |
| 38 | + <ResponseField name="tokenAddress" type="string"> |
| 39 | + Token contract address |
| 40 | + </ResponseField> |
| 41 | + <ResponseField name="tokenBalance" type="string"> |
| 42 | + Token balance in wei/smallest unit |
| 43 | + </ResponseField> |
| 44 | + <ResponseField name="tokenMetadata" type="object"> |
| 45 | + <Expandable title="properties"> |
| 46 | + <ResponseField name="decimals" type="number"> |
| 47 | + Token decimals |
| 48 | + </ResponseField> |
| 49 | + <ResponseField name="logo" type="string | null"> |
| 50 | + Token logo URL |
| 51 | + </ResponseField> |
| 52 | + <ResponseField name="name" type="string"> |
| 53 | + Token name |
| 54 | + </ResponseField> |
| 55 | + <ResponseField name="symbol" type="string"> |
| 56 | + Token symbol |
| 57 | + </ResponseField> |
| 58 | + </Expandable> |
| 59 | + </ResponseField> |
| 60 | + <ResponseField name="tokenPrices" type="array"> |
| 61 | + <Expandable title="Price object properties"> |
| 62 | + <ResponseField name="currency" type="string"> |
| 63 | + Price currency (e.g., `usd`) |
| 64 | + </ResponseField> |
| 65 | + <ResponseField name="value" type="string"> |
| 66 | + Price value |
| 67 | + </ResponseField> |
| 68 | + <ResponseField name="lastUpdatedAt" type="string"> |
| 69 | + ISO timestamp of last price update |
| 70 | + </ResponseField> |
| 71 | + </Expandable> |
| 72 | + </ResponseField> |
| 73 | + <ResponseField name="error" type="string | null"> |
| 74 | + Error message if applicable |
| 75 | + </ResponseField> |
| 76 | + </Expandable> |
| 77 | +</ResponseField> |
| 78 | + |
| 79 | +<ResponseField name="pageKey" type="string"> |
| 80 | + Pagination key for fetching more results |
| 81 | +</ResponseField> |
| 82 | + |
| 83 | +<RequestExample> |
| 84 | +```bash cURL |
| 85 | +curl -X POST https://api.heyvincent.ai/user/123/agent-funds \ |
| 86 | + -H "Content-Type: application/json" \ |
| 87 | + -d '{ |
| 88 | + "userControllerAddress": "0xUserWalletAddress...", |
| 89 | + "networks": ["base-mainnet", "base-sepolia"] |
| 90 | + }' |
| 91 | +``` |
| 92 | + |
| 93 | +```typescript TypeScript |
| 94 | +const response = await fetch(`https://api.heyvincent.ai/user/${appId}/agent-funds`, { |
| 95 | + method: 'POST', |
| 96 | + headers: { 'Content-Type': 'application/json' }, |
| 97 | + body: JSON.stringify({ |
| 98 | + userControllerAddress: userWallet.address, |
| 99 | + networks: ['base-mainnet', 'base-sepolia'] |
| 100 | + }) |
| 101 | +}); |
| 102 | + |
| 103 | +const { agentAddress, tokens } = await response.json(); |
| 104 | + |
| 105 | +console.log(`Agent address: ${agentAddress}`); |
| 106 | +tokens.forEach(token => { |
| 107 | + console.log(`${token.tokenMetadata?.symbol}: ${token.tokenBalance}`); |
| 108 | +}); |
| 109 | +``` |
| 110 | +</RequestExample> |
| 111 | + |
| 112 | +<ResponseExample> |
| 113 | +```json Response |
| 114 | +{ |
| 115 | + "agentAddress": "0xAgentSmartAccountAddress...", |
| 116 | + "tokens": [ |
| 117 | + { |
| 118 | + "address": "0xAgentSmartAccountAddress...", |
| 119 | + "network": "base-mainnet", |
| 120 | + "tokenAddress": "0xTokenContractAddress...", |
| 121 | + "tokenBalance": "1000000000000000000", |
| 122 | + "tokenMetadata": { |
| 123 | + "decimals": 18, |
| 124 | + "logo": "https://example.com/token-logo.png", |
| 125 | + "name": "USD Coin", |
| 126 | + "symbol": "USDC" |
| 127 | + }, |
| 128 | + "tokenPrices": [ |
| 129 | + { |
| 130 | + "currency": "usd", |
| 131 | + "value": "1.00", |
| 132 | + "lastUpdatedAt": "2024-01-01T00:00:00Z" |
| 133 | + } |
| 134 | + ] |
| 135 | + } |
| 136 | + ], |
| 137 | + "pageKey": "optional-pagination-key" |
| 138 | +} |
| 139 | +``` |
| 140 | +</ResponseExample> |
0 commit comments