solana_kit_rpc_subscriptions_channel_websocket 0.9.0 copy "solana_kit_rpc_subscriptions_channel_websocket: ^0.9.0" to clipboard
solana_kit_rpc_subscriptions_channel_websocket: ^0.9.0 copied to clipboard

WebSocket channel for RPC subscriptions for the Solana Kit Dart SDK.

solana_kit_rpc_subscriptions_channel_websocket #

pub package docs website CI coverage

WebSocket channel transport for Solana RPC subscriptions in the Solana Kit Dart SDK.

Use this package when you need a raw WebSocket channel to feed solana_kit_rpc_subscriptions. Most applications call createSolanaRpcSubscriptions and never touch this layer directly.

By default, channel URLs must use wss:// and may not target localhost or non-public IP literals. Alternate numeric IPv4 forms and IPv4-mapped private IPv6 literals are also rejected. This check does not resolve DNS names; do not accept arbitrary endpoint URLs from untrusted input. Controlled local tests must explicitly enable allowPrivateHosts (and allowInsecureWs for ws://).

Installation #

Install the package directly:

dependencies:
  "solana_kit_rpc_subscriptions_channel_websocket": ^0.9.0

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 a channel #

createWebSocketChannel opens a WebSocket and returns a channel with send, streams.notifications, and close.

import 'package:solana_kit_rpc_subscriptions_channel_websocket/solana_kit_rpc_subscriptions_channel_websocket.dart';
import 'package:solana_kit_subscribable/solana_kit_subscribable.dart';

Future<void> main() async {
  final source = CancellationTokenSource();
  final channel = await createWebSocketChannel(
    WebSocketChannelConfig(
      url: Uri.parse('wss://api.mainnet-beta.solana.com'),
      signal: source.token,
    ),
  );

  await channel.send('{"jsonrpc":"2.0","id":1,"method":"slotSubscribe"}');

  await for (final message in channel.streams.notifications) {
    print(message);
    source.cancel();
  }
}

Local development #

For local tests, allow ws:// and private hosts explicitly.

import 'package:solana_kit_rpc_subscriptions_channel_websocket/solana_kit_rpc_subscriptions_channel_websocket.dart';
import 'package:solana_kit_subscribable/solana_kit_subscribable.dart';

Future<void> main() async {
  final source = CancellationTokenSource();
  final channel = await createWebSocketChannel(
    WebSocketChannelConfig(
      url: Uri.parse('ws://127.0.0.1:8900'),
      allowInsecureWs: true,
      allowPrivateHosts: true,
      signal: source.token,
    ),
  );

  print(channel);
  source.cancel();
}

Key APIs #

  • createWebSocketChannel(url, {allowInsecureWs, allowPrivateHosts}).
  • WebSocketChannel with send, streams.notifications, and close.

Example #

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

  • Import path: package:solana_kit_rpc_subscriptions_channel_websocket/solana_kit_rpc_subscriptions_channel_websocket.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.
1
likes
160
points
378
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

WebSocket channel for RPC subscriptions for the Solana Kit Dart SDK.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

solana_kit_errors, solana_kit_subscribable, web_socket_channel

More

Packages that depend on solana_kit_rpc_subscriptions_channel_websocket