Skip to main content
TIPIf you only need to use the common RPC methods already supported by SolanaRpcClient, read the RPC Client usage guide.

Add dependencies

The rpc-core library provides core classes and abstractions to build and submit requests according to the JSON-RPC 2.0 specification.
build.gradle.kts

Creating a JSON RPC Request

The rpc-core library defines a JsonRpc20Request constructor to conveniently construct a Solana JSON RPC request. Populate the JSON object with the method name and JSON serialized parameters of a Solana RPC method. The constructor also includes a requestId parameter, as per JSON-RPC spec.

Example: getLatestBlockhash RPC request

Defining the JSON RPC Response

After creating the request, create Kotlin serializable classes that define the expected response payload for that request. In the following example, we are defining the expected response of the getLatestBlockhash request using the kotlinx.serialization library.

Example: getLatestBlockhash RPC response

Implement HttpNetworkDriver

The rpc-core library defines a HttpNetworkDriver interface that is used to make network requests.
You can use a common networking package like the Ktor library to implement the makeHttpRequest method. The following is an example from the Kotlin Jetpack Compose Scaffold sample app.

Sending RPC requests

After putting these parts together, use the Rpc20Driver class to point to an RPC uri, send the request, and receive a response.

Next steps

  • Browse the full list of Solana RPC HTTP Methods
Last modified on July 21, 2026