Skip to content

transactions.list()

Retrieve a paginated list of transactions with optional filtering.

Signature

transactions.list(query?: ListTransactionsQuery): Promise<PaginatedResponse<Transaction>>

Parameters

query (optional)

  • Type: ListTransactionsQuery
interface ListTransactionsQuery {
  page_size?: number;    // Results per page (default: 20, max: 100)
  page_token?: string;   // Pagination token for next page
  payer?: string;        // Filter by payer wallet address
  pay_to?: string;       // Filter by recipient wallet address
  entry_id?: string;     // Filter by specific entry ID
}

Returns

  • Type: Promise<PaginatedResponse<Transaction>>
interface PaginatedResponse<Transaction> {
  data: Transaction[];
  next_page_token?: string;
  has_more: boolean;
}
 
interface Transaction {
  id: string;
  piid?: string | null;
  payer: string;
  pay_to: string;
  amount: string;
  asset: string;
  entry_id?: string | null;
  transaction_hash: string;
  created_at: number;
}

Usage

List All Transactions

const result = await grapevine.transactions.list();
 
console.log(`Found ${result.data.length} transactions`);
result.data.forEach(tx => {
  console.log(`${tx.payer} → ${tx.pay_to}: ${formatUSDC(tx.amount)}`);
});

Filter by Payer

// Get all payments made by a wallet
const payments = await grapevine.transactions.list({
  payer: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
  page_size: 50
});
 
console.log(`Wallet made ${payments.data.length} payments`);

Filter by Recipient

// Get all payments received by a wallet (revenue)
const revenue = await grapevine.transactions.list({
  pay_to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
  page_size: 50
});
 
const totalRevenue = revenue.data.reduce(
  (sum, tx) => sum + BigInt(tx.amount),
  BigInt(0)
);
 
console.log('Total revenue:', formatUSDC(totalRevenue.toString()));

Filter by Entry

// Get all transactions for a specific piece of content
const entryTransactions = await grapevine.transactions.list({
  entry_id: '123e4567-e89b-12d3-a456-426614174000'
});
 
console.log(`Entry has ${entryTransactions.data.length} purchases`);

Combine Filters

// Get transactions between two specific wallets for a specific entry
const filtered = await grapevine.transactions.list({
  payer: buyerAddress,
  pay_to: sellerAddress,
  entry_id: entryId,
  page_size: 10
});

Manual Pagination

let allTransactions: Transaction[] = [];
let pageToken: string | undefined;
 
do {
  const result = await grapevine.transactions.list({
    payer: walletAddress,
    page_size: 100,
    page_token: pageToken
  });
  
  allTransactions.push(...result.data);
  pageToken = result.next_page_token;
  
  console.log(`Loaded ${allTransactions.length} transactions...`);
} while (pageToken);
 
console.log(`Total transactions: ${allTransactions.length}`);

Calculate Statistics

async function getTransactionStats(walletAddress: string) {
  const sent = await grapevine.transactions.list({ payer: walletAddress });
  const received = await grapevine.transactions.list({ pay_to: walletAddress });
  
  const totalSent = sent.data.reduce(
    (sum, tx) => sum + BigInt(tx.amount), 
    BigInt(0)
  );
  
  const totalReceived = received.data.reduce(
    (sum, tx) => sum + BigInt(tx.amount), 
    BigInt(0)
  );
  
  return {
    sentCount: sent.data.length,
    totalSent: formatUSDC(totalSent.toString()),
    receivedCount: received.data.length,
    totalReceived: formatUSDC(totalReceived.toString()),
    netBalance: formatUSDC((totalReceived - totalSent).toString())
  };
}
 
function formatUSDC(weiAmount: string): string {
  const usdc = Number(BigInt(weiAmount)) / 1e6;
  return `${usdc.toFixed(2)}`;
}

Response Example

{
  data: [
    {
      id: 'tx_456e7890-e89b-12d3-a456-426614174111',
      payer: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
      pay_to: '0x8Ba1f109551bD432803012645Hac136c8cb2bc43',
      amount: '1200000',  // 1.20 USDC
      asset: 'USDC',
      entry_id: '123e4567-e89b-12d3-a456-426614174000',
      transaction_hash: '0xabc123def456...',
      created_at: 1704067200
    },
    // ... more transactions
  ],
  next_page_token: 'eyJjdXJzb3IiOi4uLn0',
  has_more: true
}

Notes

  • Authentication: Not required - public endpoint
  • Ordering: Results are ordered by creation time, newest first
  • Currency: Amounts are in wei (USDC has 6 decimals, so 1000000 = 1 USDC)
  • Rate Limits: Standard API rate limits apply

Related