Skip to main content

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

wallet
Address
required
Smart account wallet address.
origin_wallet
Address
required
Origin wallet address (EOA) of the user.

Return Value

limit
number
Maximum deposit limit.

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

ErrorCauseSolution
ValidationError: wallet address is requiredMissing wallet parameterProvide a valid smart account address
ValidationError: origin wallet address is requiredMissing origin_wallet parameterProvide a valid origin wallet address

Next Steps