Skip to main content
This guide will teach you how to use the SolanaRpcClient and send these RPC requests.

Add dependencies

The rpc-core library provides a convenient SolanaRpcClient that implements an API to call these RPC methods and return responses.
build.gradle.kts

Create an RPC Client

To create an instance of a SolanaRpcClient, pass in:
  • an RPC url that the client will send requests.
  • a networkDriver used to send HTTP requests.
In this example, we construct an RPC client pointed at devnet and Ktor as a network driver:

Example: Fetching latest blockhash

Calling the getLatestBlockhash method returns an RpcResponse.
  • If successful, the response result will contain a BlockhashResult.
  • If an error occured, the response will contain an RpcError.

Example: Sending a transaction

To submit a transaction to the RPC, use the sendTransaction method.
  • If successful, the response result will contain a transaction signature string.
  • If an error occured, the response will contain an RpcError.

Next steps

These examples are just some of the methods supported by SolanaRpcClient. Here are suggestions to continue learning:
  • Read the following guide to learn how to build Solana program instructions and transactions.
  • For a complete reference of the RPC methods supported, view the SolanaRpcClient source code and unit tests.
  • Read the Building JSON RPC requests deep dive to learn how to create requests for RPC methods that aren’t immediately supported by SolanaRpcClient.
Last modified on July 21, 2026