Method Signature
agent.getLimit(params: GetLimitParams): Promise<LimitResponse>
Description
Retrieves the deposit limit for an agent. This indicates the maximum amount that can be deposited.
Parameters
Smart account wallet address.
Origin wallet address (EOA) of the user.
Return Value
Example
import { GizaAgent, Chain } from '@giza/agent-sdk';
const giza = new GizaAgent({ chainId: Chain.BASE });
// Get deposit limit
const { limit } = await giza.agent.getLimit({
wallet: smartAccountAddress,
origin_wallet: userWallet,
});
console.log('Deposit limit:', limit);
// Check if user can deposit a specific amount
const depositAmount = 1000;
if (depositAmount <= limit) {
console.log('Deposit allowed');
} else {
console.log(`Cannot deposit more than ${limit}`);
}
Output
{
limit: 100000 // Maximum deposit limit
}
Error Handling
import { ValidationError, GizaAPIError } from '@giza/agent-sdk';
try {
const { limit } = await giza.agent.getLimit({
wallet: smartAccountAddress,
origin_wallet: userWallet,
});
} catch (error) {
if (error instanceof ValidationError) {
console.error('Invalid parameters:', error.message);
} else if (error instanceof GizaAPIError) {
console.error('Failed to get limit:', error.message);
}
}
Common Errors
| Error | Cause | Solution |
|---|
ValidationError: wallet address is required | Missing wallet parameter | Provide a valid smart account address |
ValidationError: origin wallet address is required | Missing origin_wallet parameter | Provide a valid origin wallet address |
Next Steps