Skip to main content

Method Signature

agent.getTransactions(params: GetTransactionsParams): Promise<TransactionHistoryResponse>

Description

Retrieves the transaction history for an agent, including deposits, withdrawals, supplies, swaps, and claims.

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).
sort
SortOrder
Sort order for results:
  • SortOrder.DATE_ASC - Oldest first
  • SortOrder.DATE_DESC - Newest first

Return Value

transactions
Transaction[]
Array of transactions, each containing:
  • action - Transaction type (DEPOSIT, WITHDRAW, SUPPLY, WITHDRAW_SUPPLY, SWAP, CLAIM)
  • date - Transaction date
  • amount - Amount involved
  • token_type - Token address
  • status - Status (PENDING, SUCCESS, FAILED, REVERTED)
  • transaction_hash - On-chain transaction hash (optional)
  • protocol - Protocol involved (optional)
  • new_token - New token for swaps (optional)
  • apr - APR at time of transaction (optional)
pagination
PaginationInfo
Pagination metadata:
  • total_items - Total number of transactions
  • total_pages - Total number of pages
  • current_page - Current page number
  • items_per_page - Items per page

Example

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

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

// Get recent transactions
const history = await giza.agent.getTransactions({
  wallet: smartAccountAddress,
  page: 1,
  limit: 20,
  sort: SortOrder.DATE_DESC,
});

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

// Display transactions
history.transactions.forEach((tx) => {
  console.log(`${tx.date}: ${tx.action} - ${tx.amount} ${tx.token_type}`);
  console.log(`  Status: ${tx.status}`);
  if (tx.protocol) console.log(`  Protocol: ${tx.protocol}`);
});

// Paginate through all transactions
let page = 1;
while (page <= history.pagination.total_pages) {
  const result = await giza.agent.getTransactions({
    wallet: smartAccountAddress,
    page,
    limit: 50,
  });
  // Process result.transactions
  page++;
}

Output

{
  transactions: [
    {
      action: 'SUPPLY',
      date: '2024-01-16T10:30:00Z',
      amount: 500000000,
      token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
      status: 'SUCCESS',
      transaction_hash: '0x123...',
      protocol: 'aave',
      apr: 5.25
    },
    {
      action: 'DEPOSIT',
      date: '2024-01-15T12:00:00Z',
      amount: 1000000000,
      token_type: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
      status: 'SUCCESS',
      transaction_hash: '0x456...'
    }
  ],
  pagination: {
    total_items: 25,
    total_pages: 2,
    current_page: 1,
    items_per_page: 20
  }
}

Transaction Types

ActionDescription
DEPOSITUser deposited funds to the smart account
WITHDRAWUser withdrew funds from the smart account
SUPPLYAgent supplied funds to a protocol
WITHDRAW_SUPPLYAgent withdrew funds from a protocol
SWAPAgent swapped tokens
CLAIMAgent claimed rewards

Error Handling

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

try {
  const history = await giza.agent.getTransactions({
    wallet: smartAccountAddress,
    page: 1,
    limit: 20,
  });
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid parameters:', error.message);
  } else if (error instanceof GizaAPIError) {
    console.error('Failed to get transactions:', error.message);
  }
}

Next Steps