Contenu source (brut)
<p><a href="https://www.helius.dev/docs/rpc/gettransactionsforaddress"><code><span style="text-decoration: underline">getTransactionsForAddress</span></code></a> (gTFA) is a new Solana RPC method for querying <a href="https://www.helius.dev/historical-data"><span style="text-decoration: underline">historical data</span></a> that combines <code>getSignaturesForAddress</code> and <code>getTransaction</code> into a single call, with powerful new features including reverse search, time, status, and slot-based filtering, and pagination.</p><p>Until now, backfilling and querying historical data on Solana forced developers to use slow, expensive methods like <code>getBlock</code> or to loop over batches of signatures using <code>getSignaturesForAddress</code> and <code>getTransaction</code>.</p><p>Now, developers can use a single call with powerful filtering and sorting options to query up to 100 records with full transaction details or up to 1,000 records with just signatures.</p><h2><strong>Challenges of Querying Historical Data on Solana</strong></h2><p>Solana’s ledger holds every transaction ever sent on-chain. This historical data includes every mint, transfer, swap, and program interaction that has occurred since genesis. </p><p>To date, Solana has produced <strong>over 375 million blocks</strong>, and its full, unpruned transaction history from the genesis block to the present day is <strong>100s of terabytes</strong> in size. </p><p>Accessing this data quickly and reliably is essential for practically every team building on Solana today. <a href="https://www.helius.dev/docs/rpc/guides/overview#historical-data-archival"><span style="text-decoration: underline">Solana's archival methods</span></a> power everything from your favorite wallet’s transaction history tab to your favorite explorer and portfolio dashboard. </p><p>Until now, developers only had two options for querying archival data and both are painful: </p><ol class="list-number"><li value=1><code>getBlock</code></li><li value=2><code>getSignaturesForAddress</code> plus <code>getTransaction</code></li></ol><h3><strong>Using getBlock is too Slow</strong></h3><p>First, developers may try querying <a href="https://www.helius.dev/docs/api-reference/rpc/http/getblock"><code><span style="text-decoration: underline">getBlock</span></code></a> to backfill data<strong>. </strong>While possible, this method is unnecessarily time-consuming, expensive, and resource-heavy:</p><ol class="list-number"><li value=1>Call <code>getBlocks</code> to find confirmed blocks in your slot range</li><li value=2>Call <code>getBlock</code> on each block to get full transaction details, signatures, or accounts</li><li value=3>Parse all relevant data from the block and store it in your database</li><li value=4>Repeat until all blocks are complete</li></ol><p>While the <code>getBlock</code> method works well for busy programs (e.g., indexing popular tokens like USDC or Solana programs like Pump.fun), using it for small, specific datasets is impractical.</p><h3><strong>Looping getSignaturesForAddress and getTransaction</strong></h3><p>Using <a href="https://www.helius.dev/docs/api-reference/rpc/http/getsignaturesforaddress"><code><span style="text-decoration: underline">getSignaturesForAddress</span></code></a> (gSFA) together with <a href="https://www.helius.dev/docs/api-reference/rpc/http/gettransaction"><code><span style="text-decoration: underline">getTransaction</span></code></a><strong> </strong>is another common way to backfill data. </p><p>This “N+1 loop” approach repeatedly fetches transaction signatures, typically 1,000 at a time, and then makes batch RPC calls to fetch the details of each transaction. </p><p>Given the sheer number of RPC requests, developers will need to implement exponential backoffs and retry logic to avoid hitting rate limits and missing data. </p><p>While using gSFA and <code>getTransaction</code> is more flexible than <code>getBlock</code>, it’s still expensive, complicated, and error-prone at scale.</p><h2><strong>Benefits of getTransactionForAddress</strong></h2><p>The new <a href="https://www.helius.dev/docs/api-reference/rpc/http/gettransactionsforaddress"><code><span style="text-decoration: underline">getTransactionsForAddress</span></code><span style="text-decoration: underline"> RPC method</span></a> combines <code>getSignaturesForAddress</code> with <code>getTransaction</code> into a single call with powerful features that make building indexes and querying historical data easier and faster.</p><p>Here are the key features:</p><h3><strong>1. Reverse Search</strong></h3><p>Existing archival RPC methods, such as gSFA, required developers to start at the most recent transaction and work backward. </p><p>With <code>getTransactionForAddress</code>, developers can now choose between <strong>ascending</strong> (i.e., chronologically, oldest first) or <strong>descending</strong> (i.e., newest first) sort orders. </p><p>Combined with time-based filters, developers can use <code>getTransactionForAddress</code> to query any piece of Solana’s history, from any point in time, in any order.</p><p>For example, <a href="https://orb.helius.dev">Orb</a>, our new Solana block explorer, uses the <code>getTransactionsForAddress</code> RPC method to power the “Show oldest first” filter:</p><img src="/_next/image?url=/api/media/file/orb-show-oldest-first-filter.jpg&w=3840&q=90" alt="Orb using getTransactionsForAddress RPC method to show oldest transactions first for the hSOL token" /><p>If you wanted to query this same data using <code>getSignaturesForAddress</code> and <code>getTransaction</code>, you would need to:</p><ol class="list-number"><li value=1>Find the exact timestamp corresponding to the first transaction</li><li value=2>Find the transaction signature corresponding to your start date</li><li value=3>Loop backward from that signature using <code>before: lastSignature</code><strong> </strong></li><li value=4>Continue looping until the returned signatures' <code>blockTime</code> reaches the end date</li><li value=5>Write backoff and retry logic to avoid hitting rate limits and missing data</li></ol><p>This process is not only slow to query but also frustrating to set up and prone to error.</p><h3><strong>2. Advanced Filtering</strong></h3><p>With the new <code>getTransactionsForAddress</code> method, developers can filter by time range (i.e., Unix timestamp), slot, and status (e.g., succeeded or failed). These <a href="https://www.helius.dev/docs/rpc/gettransactionsforaddress#filter-operators"><span style="text-decoration: underline">filters</span></a> give you more precise, granular control over querying exactly the data you need.</p><p>For example, this time-based filter uses Unix timestamps to receive all successful transactions that occurred between January 1st, 2025, at 12:00 am (GMT) and October 1st, 2025, at 12:00 am (GMT).</p><pre><code>// Time range with successful transactions only
"filters": {
"blockTime": {
"gte": 1767225600,
"lte": 1759363200
},
"status": "succeeded"
}</code></pre><h3><strong>3. Cursor-based Pagination</strong></h3><p>When you need to query more transactions than gTFA’s default limits (1,000 signatures or 100 records with full transaction details), you can use the <code>paginationToken</code> from the response to <a href="https://www.helius.dev/docs/rpc/gettransactionsforaddress#pagination"><span style="text-decoration: underline">fetch the next page</span></a>. The <code>paginationToken</code> is a simple string in the format "slot:position" that tells the API from where to continue.</p><p>For example, this query uses the <code>paginationToken</code> (a cursor) to scan the addresses’ history in batches of 100.</p><pre><code>// First request
let paginationToken = null;
let allTransactions = [];
const getNextPage = async (paginationToken = null) => {
const params = [
'ADDRESS',
{
transactionDetails: 'signatures',