RPC Best Practices
A condensed summary of the 25 most important RPC practices drawn from every page in this section.
Search across all documentation pages
A condensed summary of the 25 most important RPC practices drawn from every page in this section.
Never ship production on public RPC: Use a paid provider or self-hosted node with SLA (RPC Providers).
Store keys in environment variables: Never commit API keys; proxy sensitive reads through your backend.
Pair HTTP and WSS URLs: Subscriptions need wss:// from the same vendor dashboard (WebSocket Subscriptions).
Set commitment explicitly: Default to confirmed for UX; finalized for treasury (RPC Basics).
Null-check getAccountInfo: value: null means missing account - do not decode blindly (Core RPC Methods).
Prefer getMultipleAccounts: Batch known pubkeys instead of N serial getAccountInfo calls.
Never run unfiltered GPA on mainnet: Always memcmp/dataSize filter or use an indexer (getProgramAccounts & Filters).
Chunk large batches: 50-100 accounts per getMultipleAccounts request (Pagination & Efficiency).
Paginate signatures server-side: getSignaturesForAddress cursoring belongs in your API, not mobile clients for whales.
Abort WebSocket subscriptions: Clean up on unmount to avoid connection leaks.
Use signatureNotifications for confirms: Prefer subscriptions over 200ms polling loops.
Simulate before mainnet sends: Read unitsConsumed and logs (Priority Fee & Simulation APIs).
Refresh priority fees per batch: getRecentPrioritizationFees stale samples underprice during congestion.
Add CU headroom: Set compute unit limit to 110% of simulated consumption.
Use DAS for wallet NFTs: getAssetsByOwner beats manual metadata GPA (The DAS API).
Keep DAS and RPC URLs documented: They may differ on provider dashboards.
Implement RPC failover: Secondary URL on 429/503 with exponential backoff.
Rate-limit your own clients: Protect provider quota from retry storms.
Align CLI and app RPC: solana config get should match RPC_URL when debugging.
Cache immutable data only: Short TTL for mint metadata; never cache post-swap balances without invalidation.
Monitor slot lag: getSlot RTT and stall detection alert unhealthy endpoints.
Avoid heavy getTransaction in browsers: Proxy through indexer for history views.
Use jsonParsed selectively: Fall back to base64 + IDL decode when parser unsupported.
Plan indexer migration early: If GPA or history scans exceed thousands of rows, start Geyser pipeline (Indexing Basics).
Pin @solana/kit 7.0.0: Typed RPC reduces param bugs vs raw fetch.
Unfiltered mainnet getProgramAccounts in production - timeouts, cost, and bans.
Local prototypes and rare CLI use only - not user-facing mainnet traffic.
Simulation and priority fee RPCs feed compute budget decisions - see tx optimization section.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026