Method Signature
agent.getDeposits(wallet: Address, isOriginWallet?: boolean): Promise<DepositListResponse>
Description
Retrieves the list of deposits made to an agent’s smart account.
Parameters
Smart account wallet address (or origin wallet if isOriginWallet is true).
Set to true if the wallet parameter is an origin wallet address.
Return Value
Array of deposits, each containing:
amount - Deposit amount (in token’s smallest unit)
token_type - Token address
date - Deposit date (optional)
tx_hash - Transaction hash (optional)
Example
import { GizaAgent, Chain } from '@giza/agent-sdk';
const giza = new GizaAgent({ chainId: Chain.BASE });
// Get deposits by smart account address
const deposits = await giza.agent.getDeposits(smartAccountAddress);
console.log(`Total deposits: ${deposits.deposits.length}`);
deposits.deposits.forEach((deposit) => {
console.log(`Amount: ${deposit.amount}`);
console.log(` Token: ${deposit.token_type}`);
if (deposit.date) console.log(` Date: ${deposit.date}`);
if (deposit.tx_hash) console.log(` Hash: ${deposit.tx_hash}`);
});
// Calculate total deposited
const totalDeposited = deposits.deposits.reduce(
(sum, d) => sum + d.amount,
0
);
console.log(`Total deposited: ${totalDeposited}`);
// Get deposits by origin wallet
const depositsByOrigin = await giza.agent.getDeposits(userWallet, true);
Output
{
deposits: [
{
amount: 1000000000,
token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
date: '2024-01-15T12:00:00Z',
tx_hash: '0x123...'
},
{
amount: 500000000,
token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
date: '2024-01-20T10:00:00Z',
tx_hash: '0x456...'
}
]
}
Error Handling
import { ValidationError, GizaAPIError } from '@giza/agent-sdk';
try {
const deposits = await giza.agent.getDeposits(smartAccountAddress);
} catch (error) {
if (error instanceof ValidationError) {
console.error('Invalid wallet address:', error.message);
} else if (error instanceof GizaAPIError) {
console.error('Failed to get deposits:', error.message);
}
}
Common Errors
| Error | Cause | Solution |
|---|
ValidationError: wallet address is required | Missing wallet parameter | Provide a valid wallet address |
ValidationError: wallet address must be a valid Ethereum address | Invalid address format | Ensure address starts with 0x and has 40 hex characters |
Next Steps