solana_kit_rpc_spec 0.9.3 copy "solana_kit_rpc_spec: ^0.9.3" to clipboard
solana_kit_rpc_spec: ^0.9.3 copied to clipboard

RPC specification implementation for the Solana Kit Dart SDK.

solana_kit_rpc_spec #

pub package docs website CI coverage

The transport-agnostic core of the Solana RPC stack: Rpc, RpcRequest, RpcTransport, and the createRpc factory that binds an API map to a transport.

Use this package when you are building a custom RPC client or transport. Most applications use solana_kit_rpc, which composes this core with the Solana method set and HTTP transport.

Installation #

Install the package directly:

dependencies:
  "solana_kit_rpc_spec": ^0.9.3

If your app uses several Solana Kit packages together, you can also depend on the umbrella package instead:

dart pub add solana_kit

Inside this monorepo, Dart workspace resolution uses the local package automatically.

Documentation #

For architecture notes, getting-started guides, and cross-package examples, start with the workspace docs site and then drill down into the package README and API reference.

Usage #

Creating an RPC over a custom transport #

createRpc binds an API map to a transport function. Each API entry returns an RpcPlan that describes how to execute the request.

import 'package:solana_kit_rpc_spec/solana_kit_rpc_spec.dart';
import 'package:solana_kit_rpc_spec_types/solana_kit_rpc_spec_types.dart';

Future<void> main() async {
  final rpc = createRpc(
    RpcConfig(
      api: MapRpcApi({
        'ping': (params) {
          return RpcPlan<Object?>(
            execute: (config) => config.transport(
              RpcTransportConfig(
                payload: createRpcMessage(
                  RpcRequest<List<Object?>>(methodName: 'ping', params: params),
                ),
                signal: config.signal,
              ),
            ),
          );
        },
      }),
      transport: (_) async => <String, Object?>{'ok': true},
    ),
  );

  final result = await rpc.request('ping', ['demo']).send();
  print('RPC result: $result');
}

Pending requests #

rpc.request(...) returns a PendingRpcRequest<T> that only executes when you call .send(). This lets callers build, cache, and batch requests before hitting the network.

import 'package:solana_kit_rpc_spec/solana_kit_rpc_spec.dart';

Future<void> main() async {
  final rpc = createRpc(
    RpcConfig(
      api: MapRpcApi({}),
      transport: (_) async => <String, Object?>{'result': 1},
    ),
  );

  final pending = rpc.request<Object?>('getSlot', <Object?>[]);
  final result = await pending.send();
  print(result);
}

Key APIs #

  • Rpc, RpcRequest<T>, RpcResponse<T>, PendingRpcRequest<T>.
  • createRpc, RpcConfig, MapRpcApi, RpcPlan.
  • RpcTransport, RpcTransportConfig, createRpcMessage.

Example #

Use example/main.dart as a runnable starting point for solana_kit_rpc_spec.

  • Import path: package:solana_kit_rpc_spec/solana_kit_rpc_spec.dart
  • This section is centrally maintained with mdt to keep package guidance aligned.
  • After updating shared docs templates, run docs:update from the repo root.

Maintenance #

  • Validate docs in CI and locally with docs:check.
  • Keep examples focused on one workflow and reference package README sections for deeper API details.
0
likes
160
points
3k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

RPC specification implementation for the Solana Kit Dart SDK.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

solana_kit_errors, solana_kit_rpc_spec_types, solana_kit_subscribable

More

Packages that depend on solana_kit_rpc_spec