Skip to main content

Method Signature

agent.getWithdrawalHistory(
  wallet: Address,
  page?: number,
  limit?: number
): Promise<TransactionHistoryResponse>

Description

Retrieves only withdrawal transactions for an agent. This is a filtered view of getTransactions() showing only WITHDRAW actions.

Parameters

wallet
Address
required
Smart account wallet address.
page
number
default:"1"
Page number for pagination (starts at 1).
limit
number
default:"20"
Number of items per page (max 100).

Return Value

transactions
Transaction[]
Array of withdrawal transactions only.
pagination
PaginationInfo
Pagination metadata for the filtered results.

Example

import { GizaAgent, Chain } from '@giza/agent-sdk';

const giza = new GizaAgent({ chainId: Chain.BASE });

// Get withdrawal history
const withdrawals = await giza.agent.getWithdrawalHistory(
  smartAccountAddress,
  1,  // page
  20  // limit
);

console.log(`Total withdrawals: ${withdrawals.pagination.total_items}`);

withdrawals.transactions.forEach((tx) => {
  console.log(`${tx.date}: ${tx.amount} ${tx.token_type}`);
  console.log(`  Status: ${tx.status}`);
  if (tx.transaction_hash) {
    console.log(`  Hash: ${tx.transaction_hash}`);
  }
});

Output

{
  transactions: [
    {
      action: 'WITHDRAW',
      date: '2024-01-20T15:30:00Z',
      amount: 1000000000,
      token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
      status: 'SUCCESS',
      transaction_hash: '0x123...'
    },
    {
      action: 'WITHDRAW',
      date: '2024-01-10T10:00:00Z',
      amount: 500000000,
      token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
      status: 'SUCCESS',
      transaction_hash: '0x456...'
    }
  ],
  pagination: {
    total_items: 2,
    total_pages: 1,
    current_page: 1,
    items_per_page: 20
  }
}

Error Handling

import { ValidationError, GizaAPIError } from '@giza/agent-sdk';

try {
  const withdrawals = await giza.agent.getWithdrawalHistory(
    smartAccountAddress
  );
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid wallet address:', error.message);
  } else if (error instanceof GizaAPIError) {
    console.error('Failed to get withdrawal history:', error.message);
  }
}

Next Steps