> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getTransactionCount

> Returns the current transaction count from the ledger

## Parameters

<ResponseField name="config" type="object" optional>
  Configuration object containing:

  <ResponseField name="commitment" type="string" optional>
    Commitment level (processed, confirmed, finalized)
  </ResponseField>
</ResponseField>

## Response

<ResponseField name="result" type="number">
  The current transaction count
</ResponseField>

## Code Examples

### Basic Request

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTransactionCount"
}'
```

### Using web3.js

```typescript theme={null}
import { Connection } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');

// Get transaction count
const count = await connection.getTransactionCount();
console.log('Transaction count:', count);

// Get transaction count with analysis
async function getTransactionCountWithAnalysis(
  config: { commitment?: string }
) {
  const count = await connection.getTransactionCount(config);
  
  return {
    count,
    analysis: {
      timestamp: Date.now(),
      commitment: config.commitment
    }
  };
}
```

## Notes

1. Returns the current transaction count from the ledger
2. The count includes all transactions processed by the node
3. The response is immediate as it reads from the current state
4. The count can change with new transactions
5. The count may vary between nodes due to network propagation

## Best Practices

1. Use appropriate commitment level based on your needs
2. Cache results when appropriate to reduce RPC load
3. Monitor for changes in transaction count
4. Consider using websocket subscription for real-time updates
5. Handle network errors and retry when appropriate

## Common Errors

| Code   | Message          | Solution                                     |
| ------ | ---------------- | -------------------------------------------- |
| -32601 | Method not found | Verify you're connected to a Solana RPC node |
| -32602 | Invalid params   | Check configuration parameters               |

## Use Cases

1. **Transaction Count Analysis**
   ```typescript theme={null}
   interface TransactionCountAnalysis {
     count: number;
     metrics: {
       timestamp: number;
       commitment?: string;
     };
   }

   class TransactionCountAnalyzer {
     async analyzeTransactionCount(
       config: { commitment?: string }
     ): Promise<TransactionCountAnalysis> {
       const count = await connection.getTransactionCount(config);
       
       return {
         count,
         metrics: {
           timestamp: Date.now(),
           commitment: config.commitment
         }
       };
     }
   }
   ```

2. **Transaction Count Monitoring**
   ```typescript theme={null}
   interface TransactionCountChange {
     changes: {
       previousCount: number;
       currentCount: number;
       difference: number;
       percentageChange: number;
     };
     metadata: {
       timestamp: number;
     };
   }

   class TransactionCountMonitor {
     private previousCount: number | null = null;
     
     async monitorTransactionCount(
       config: { commitment?: string }
     ): Promise<TransactionCountChange | null> {
       const currentCount = await connection.getTransactionCount(config);
       
       if (this.previousCount !== null && this.previousCount !== currentCount) {
         const difference = currentCount - this.previousCount;
         const percentageChange = (difference / this.previousCount) * 100;
         
         this.previousCount = currentCount;
         
         return {
           changes: {
             previousCount: this.previousCount,
             currentCount,
             difference,
             percentageChange
           },
           metadata: {
             timestamp: Date.now()
           }
         };
       }
       
       this.previousCount = currentCount;
       return null;
     }
   }
   ```

3. **Transaction Count Planning**
   ```typescript theme={null}
   interface TransactionCountPlan {
     currentCount: number;
     recommendations: Array<{
       type: 'scale' | 'optimize' | 'monitor';
       reason: string;
     }>;
     metadata: {
       timestamp: number;
     };
   }

   class TransactionCountPlanner {
     private readonly maxTransactionsPerSecond = 1000;
     private readonly minTransactionsPerSecond = 100;
     
     async planTransactionCount(
       config: { commitment?: string }
     ): Promise<TransactionCountPlan> {
       const currentCount = await connection.getTransactionCount(config);
       
       const recommendations: Array<{
         type: 'scale' | 'optimize' | 'monitor';
         reason: string;
       }> = [];
       
       // Check for high transaction rate
       if (currentCount > this.maxTransactionsPerSecond) {
         recommendations.push({
           type: 'scale',
           reason: `Transaction count (${currentCount}) exceeds maximum (${this.maxTransactionsPerSecond})`
         });
       }
       
       // Check for low transaction rate
       if (currentCount < this.minTransactionsPerSecond) {
         recommendations.push({
           type: 'optimize',
           reason: `Transaction count (${currentCount}) below minimum (${this.minTransactionsPerSecond})`
         });
       }
       
       return {
         currentCount,
         recommendations,
         metadata: {
           timestamp: Date.now()
         }
       };
     }
   }
   ```
