Summary
Solana RPC API is a JSON-RPC 2.0 interface for reading on-chain state, submitting transactions, and subscribing to live updates. It supports HTTP POST for request-response methods and WebSocket for subscription methods. Use it to build wallets, dApps, and indexers. Core HTTP calls include getAccountInfo, getBalance, getProgramAccounts, getLatestBlockhash, sendTransaction, simulateTransaction, getBlock, and getSlot. The same method set runs on mainnet, devnet, and testnet, but use the environment that matches your workflow: mainnet uses real SOL, devnet uses test SOL from the official faucet, and testnet is for validator testing. Public endpoints (https://api.mainnet-beta.solana.com and https://api.devnet.solana.com) are fine for experiments; production workloads should verify provider rate limits, archive support, and WebSocket availability. Every method accepts an optional commitment parameter—processed, confirmed, or finalized—that determines how recent the returned data is. For transactions, simulate first, then submit with a recent blockhash, and confirm through signature status or WebSocket. Check the OnFinality Solana network page for endpoint details before you build.
Key Takeaways
- Solana RPC uses JSON-RPC 2.0 over HTTP for request-response calls and WebSocket for subscriptions.
- Core methods cover accounts, programs, blocks, transactions, and cluster state; use filters for heavy methods like getProgramAccounts.
- Commitment levels (processed, confirmed, finalized) control consistency; choose confirmed for real-time, finalized for historical.
- Public endpoints are shared and rate-limited; production requires verifying provider limits, WebSocket, archive, and region coverage.
JSON-RPC request and response structure
Solana RPC uses the JSON-RPC 2.0 protocol over HTTPS for request-response calls. A request includes jsonrpc, id, method, and params; a successful response returns the same id and a result, while errors contain an error object with code and message. Most methods require a base58-encoded public key or a transaction signature as a parameter.
The public cluster endpoints are stable and documented: mainnet https://api.mainnet-beta.solana.com and devnet https://api.devnet.solana.com. Testnet also exists; Devnet is the preferred environment for development and testing because it uses test SOL from the official faucet at https://faucet.solana.com. The OnFinality Solana network page lists an HTTPS endpoint and WebSocket endpoint; current plan details and regions should be verified in the documentation.
- Use HTTP POST for request-response methods.
- Set
Content-Type: application/json. - Check the
errorobject in responses for RPC-specific failures.
Accounts and program methods
Account queries are the foundation for most Solana dApps. getAccountInfo returns the account state, owner, lamports, and executable flag; getBalance returns the lamport balance; getMultipleAccounts fetches multiple accounts efficiently.
getProgramAccounts returns all accounts owned by a program. It is one of the most resource-intensive Solana RPC methods, so always include filters for dataSize or memcmp to limit the result set. Otherwise you may time out or hit provider limits.
getAccountInfo– full account metadata for one addressgetBalance– lamport balancegetMultipleAccounts– batch account readsgetProgramAccounts– accounts owned by a program, filtered by size or content
Blocks, slots, and historical data
Solana produces slots; a block is created only when the slot has a leader and transactions. getSlot returns the current slot, getBlock returns a block by slot, and getBlocks returns a range of slots. getBlockHeight returns the latest block height.
For historical transaction data, getSignaturesForAddress returns confirmed signatures for an address, and getTransaction fetches the full transaction by signature. If you need deep history, confirm that your provider has archive support. The OnFinality Solana network page lists archive support for mainnet; availability may depend on your plan, so check current documentation before relying on it.
Transaction simulation, submission, and confirmation
The transaction lifecycle has four steps: fetch a recent blockhash, build and sign the transaction, optionally simulate, then submit. getLatestBlockhash returns the blockhash and last valid block height; simulateTransaction runs the transaction without broadcasting, which reveals errors and consumed compute units.
sendTransaction submits a signed transaction and returns a signature if the RPC accepts it. Confirm finality with getSignatureStatuses or a signatureSubscribe WebSocket subscription. For development, use devnet test SOL from the faucet; see the Solana devnet guide for a walkthrough.
- 1. Call
getLatestBlockhash - 2. Build and sign transaction with your keypair
- 3. Test with
simulateTransaction - 4. Submit with
sendTransaction - 5. Confirm with
getSignatureStatusesorsignatureSubscribe
WebSocket subscriptions for real-time updates
WebSocket subscriptions are more efficient than polling. Connect to a WebSocket endpoint (e.g., wss://api.mainnet-beta.solana.com) and send a JSON-RPC subscribe request. The server pushes notifications until you send an unsubscribe request or close the connection.
Common subscriptions include accountSubscribe for account changes, logsSubscribe for program logs, programSubscribe for program-owned account changes, signatureSubscribe for transaction confirmations, and slotSubscribe for new slots. Always include a commitment level in the subscription request to control how recent the data must be.
accountSubscribe– account data changeslogsSubscribe– program logsprogramSubscribe– program-owned account updatessignatureSubscribe– transaction confirmationslotSubscribe– new slot notifications
Commitment levels and consistency
For wallet balances and transaction confirmations, confirmed is often sufficient. For archival or accounting data, use finalized to avoid reorgs. Some methods like getSlot and getLatestBlockhash accept commitment; always specify it to avoid defaults.
| Criterion | What to check | Why it matters |
|---|---|---|
| processed | The node's most recent block; can be rolled back. | Fastest response but weakest consistency. |
| confirmed | The block has been voted by a supermajority of stake. | Best balance for transaction status and real-time updates. |
| finalized | The block is fully finalized with maximum lockout. | Strongest consistency for historical queries and financial records. |
Production API checklist
Before moving to production, verify that your RPC endpoint covers the methods, transports, and regions your product needs. Check the OnFinality Solana network page for current endpoint details, regions, archive support, and WebSocket availability; plan terms can change, so cross-check the documentation. For access setup, see the Solana access guide.
For provider evaluation, see Best Solana RPC provider.
- Test the exact request patterns your frontend and backend will use.
- Confirm WebSocket access if you use subscriptions.
- Check archive support if you need historical data beyond recent slots.
- Verify rate limits and upgrade paths for sustained traffic.
- Use devnet for staging and test SOL from the official faucet.
- Monitor error rates, latency, and usage before full rollout.
Frequently Asked Questions
What is the difference between HTTP and WebSocket Solana RPC methods?
HTTP methods are request-response: you send a request and get a single response. WebSocket subscriptions push updates continuously until you unsubscribe, which is more efficient for real-time account, transaction, and log monitoring.
How do I get test SOL for devnet?
Use the official Solana faucet at https://faucet.solana.com to request devnet SOL. For a full walkthrough, see the Solana devnet guide.
Which commitment level should I use for transaction confirmations?
Use confirmed for most real-time applications. Use finalized when you need maximum safety for financial or archival data. processed is only for speed-tolerant views where reorg risk is acceptable.
Can I use the public Solana RPC endpoint in production?
Public endpoints are shared and rate-limited, making them unsuitable for production. Use a managed provider and verify limits, WebSocket support, archive availability, and region coverage. See Best Solana RPC provider and the Solana network page.
How do I connect to OnFinality's Solana RPC?
Check the Solana network page for the current HTTPS and WebSocket endpoints. API key setup and access details are covered in the Solana access guide.
What is the difference between getLatestBlockhash and getSlot?
getLatestBlockhash returns the latest blockhash and its last valid block height, which are needed for transaction construction. getSlot returns the current slot number without the transaction validity window.