RPC — Remote Procedure Call
Understanding Solana's JSON-RPC interface, node types, and how to choose the right RPC provider.
What is an RPC Node?
An RPC (Remote Procedure Call) node is a Solana validator or dedicated server that exposes the Solana JSON-RPC API. Applications interact with the Solana network exclusively through RPC nodes — they cannot connect to the peer-to-peer network directly. Every wallet, DEX, trading bot, and analytics platform depends on RPC nodes for reading blockchain state and submitting transactions.
The Solana JSON-RPC API follows the JSON-RPC 2.0 specification, accepting HTTP POST requests with JSON payloads. Most methods are also available via WebSocket subscriptions for real-time updates.
RPC Node Types
Not all RPC nodes are equal. The type of node significantly affects what data is accessible and at what latency:
| Node Type | Data Available | Latency | Use Case |
|---|---|---|---|
| Standard RPC | Recent blocks (~2 epochs) | Low | Most applications |
| Archival RPC | Full history since genesis | Medium | Historical queries, analytics |
| Dedicated RPC | Configurable | Lowest | High-frequency trading, production |
| Validator RPC | Current state + recent | Lowest possible | MEV, ultra-low latency |
Core RPC Methods
The Solana RPC API provides over 40 methods. The most frequently used in production applications are:
Account and Balance Queries
const { Connection, PublicKey } = require('@solana/web3.js');
const connection = new Connection('https://api.mainnet-beta.solana.com');
// Get account balance
const balance = await connection.getBalance(
new PublicKey('YourWalletAddress')
);
console.log(`Balance: ${balance / 1e9} SOL`);
// Get full account info
const accountInfo = await connection.getAccountInfo(
new PublicKey('YourAccountAddress')
);
// Get multiple accounts in one call (more efficient)
const accounts = await connection.getMultipleAccountsInfo([
new PublicKey('Address1'),
new PublicKey('Address2'),
]);Transaction Queries
// Get transaction by signature
const tx = await connection.getTransaction(
'YourTransactionSignature',
{ maxSupportedTransactionVersion: 0 }
);
// Get signatures for an address (paginated)
const signatures = await connection.getSignaturesForAddress(
new PublicKey('YourAddress'),
{ limit: 100 }
);
// Get recent block
const block = await connection.getBlock(slot, {
maxSupportedTransactionVersion: 0,
transactionDetails: 'full',
});Sending Transactions
const { Transaction, SystemProgram, sendAndConfirmTransaction } = require('@solana/web3.js');
const transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: sender.publicKey,
toPubkey: recipient,
lamports: 1000000, // 0.001 SOL
})
);
// Get latest blockhash for transaction validity
const { blockhash, lastValidBlockHeight } =
await connection.getLatestBlockhash();
transaction.recentBlockhash = blockhash;
transaction.feePayer = sender.publicKey;
const signature = await sendAndConfirmTransaction(
connection, transaction, [sender]
);WebSocket Subscriptions
For real-time updates, Solana RPC nodes expose WebSocket endpoints. Subscriptions allow applications to receive push notifications instead of polling:
// Subscribe to account changes
const subscriptionId = connection.onAccountChange(
new PublicKey('AccountToWatch'),
(accountInfo, context) => {
console.log('Account updated:', accountInfo.lamports);
},
'confirmed'
);
// Subscribe to new slots
const slotSubscription = connection.onSlotChange((slotInfo) => {
console.log('New slot:', slotInfo.slot);
});
// Subscribe to logs for a program
const logsSubscription = connection.onLogs(
new PublicKey('ProgramId'),
(logs) => {
console.log('Program logs:', logs.logs);
}
);Commitment Levels
Solana RPC methods accept a commitment parameter that determines which version of the blockchain state to query. Understanding commitment levels is critical for building reliable applications:
| Commitment | Description | Latency | Recommended For |
|---|---|---|---|
| processed | Latest slot seen by node (may be rolled back) | ~400ms | UI updates only |
| confirmed | Voted on by supermajority (very unlikely to roll back) | ~800ms | Most applications |
| finalized | Locked in, cannot be rolled back | ~13s | Payments, critical operations |
processed commitment for financial operations is dangerous. A transaction may appear successful but later be rolled back. Always use confirmed or finalized for operations involving real value.Rate Limits and Performance
Public RPC endpoints (api.mainnet-beta.solana.com) have strict rate limits: 100 requests per 10 seconds per IP for most methods. Production applications require dedicated or premium RPC providers. Key performance metrics to evaluate when choosing a provider include:
- Latency: Time from request to response (target: <50ms for most methods)
- Throughput: Maximum requests per second
- Uptime SLA: Guaranteed availability percentage
- Geographic coverage: Proximity to your application servers
- Archive depth: How far back historical queries can reach
Choosing an RPC Provider
For production applications, the choice of RPC provider significantly impacts user experience and application reliability. See the Infrastructure Providers Comparison page for a detailed analysis of available options, including HighTower and Supanode.