Soroban Rpc Request
@Serializable
Represents a JSON-RPC 2.0 request sent to the Soroban RPC server.
All Soroban RPC API calls use the JSON-RPC 2.0 protocol over HTTP. This class provides a type-safe wrapper for constructing requests with proper serialization.
JSON-RPC 2.0 Request Structure
A valid JSON-RPC 2.0 request contains:
jsonrpc: Protocol version (always "2.0")id: Unique identifier for matching requests to responsesmethod: Name of the RPC method to invokeparams: Method-specific parameters (optional, can be null)
Example Usage
// Create a request to get health status
val request = SorobanRpcRequest(
id = "1",
method = "getHealth",
params = null
)
// Create a request with parameters
val ledgerRequest = SorobanRpcRequest(
id = "2",
method = "getLedgerEntries",
params = GetLedgerEntriesRequest(keys = listOf("..."))
)Content copied to clipboard
Serialization
This class uses kotlinx.serialization for JSON encoding/decoding. The jsonrpc field is serialized as "jsonrpc" (not "jsonRpc") to comply with the JSON-RPC specification.
Parameters
T
The type of the request parameters (can be nullable for parameter-less methods)