RPC requests
Read and write data to the blockchain
Solana applications interact with the network through a JSON-RPC server. RPC requests are how your code reads onchain state, simulates transactions, and submits transactions to be processed. Kit ships a fully typed RPC client and exposes it on Kit clients via plugins, so the same RPC API is available whether you compose a client or use the lower-level building blocks directly.
Kit aims to support every method documented in the Solana RPC HTTP methods docs. You can either browse the methods in the official documentation or rely on TypeScript autocompletion in your editor.
Installation
You will typically install Kit alongside the RPC plugin package.
The @solana/kit-plugin-rpc package contains the plugins that install RPC connectivity on a client. The @solana/kit package contains the lower-level RPC primitives those plugins are built on top of, so you can also use it standalone if you prefer not to use a client.
Create an RPC client
The most convenient way to make RPC requests is to compose a Kit client with one of the bundle plugins, which install both client.rpc and client.rpcSubscriptions in one call.
The bundle plugins also wire up minimum balance computation, transaction planning, and transaction sending, which you will use in the other guides. If you only need to make read-only RPC requests, you can drop the signer plugin and use solanaRpcConnection(...) instead, which only installs client.rpc and client.rpcSubscriptions.
Send your first RPC request
Once you have an RPC client, you build a request by calling the corresponding method on client.rpc and finalize it with .send(). Most RPC responses come back wrapped in a { context, value } object, so destructuring value is a common pattern.
Although client.rpc looks like a regular object, it is actually a Proxy that constructs RPC requests on demand. TypeScript provides type safety for every method based on the API installed by your plugin, which makes the available methods discoverable from your editor while keeping the bundle small.
Use cluster-specific RPC bundles
The @solana/kit-plugin-rpc package ships several bundle plugins, each tailored to a specific use case. The cluster-typed variants type the RPC API to match what is available on that cluster, which prevents accidents like calling airdrop against mainnet at compile time.
| Plugin | Default endpoint | Adds to the client |
|---|---|---|
solanaRpc(config) | provided via rpcUrl | RPC, subscriptions, planning, sending |
solanaMainnetRpc(...) | provided via rpcUrl | mainnet-typed RPC, subscriptions, planning, sending |
solanaDevnetRpc(...) | https://api.devnet.solana.com | devnet-typed RPC, subscriptions, planning, sending, airdrop |
solanaLocalRpc(...) | http://127.0.0.1:8899 | localnet RPC, subscriptions, planning, sending, airdrop |
If you need to talk to a custom RPC provider, pass its URL through solanaRpc({ rpcUrl: '...' }) or solanaMainnetRpc({ rpcUrl: '...' }). The other settings on SolanaRpcConfig cover advanced options such as transport configuration and transaction planner overrides.
Pass request options
Most RPC methods accept a configuration object as their final argument. This is where you control things like the requested commitment level, encoding, or pagination, depending on the method.
The .send(...) call itself accepts an optional abortSignal that lets you cancel the request in flight.
Use RPC without a client
If you do not need a Kit client, you can build an Rpc object directly with createSolanaRpc. This is useful when you want maximum tree-shaking, when you are writing a library that should not assume a client, or when you simply want to keep your dependency surface small.
The standalone Rpc object exposes the exact same API as client.rpc, so any code that takes an Rpc will work in either setup. See the Kit without a client guide for more on this approach.
Choose an RPC endpoint
For light development or personal use, the public RPC endpoints maintained by the Solana Foundation are a fine starting point.
https://api.mainnet-beta.solana.comhttps://api.testnet.solana.comhttps://api.devnet.solana.com
These endpoints are heavily rate-limited and should not be used for anything close to production traffic. When you ship to production, lease an RPC node from a provider or run your own. Some RPC providers also expose extra methods on top of the standard JSON-RPC API; many of them ship a Kit-compatible SDK that you can layer on top of createSolanaRpc(...) to merge their additional methods into the typed RPC object.
Next steps
- RPC subscriptions — receive live updates from a WebSocket endpoint.
- Fetching accounts — go from raw account bytes to typed data.
- Sending transactions — submit transactions through your client.