Status & Disclaimer: NKaspa (0.1.11-alpha on NuGet) is alpha software and has not been security-audited. It is an MIT-licensed community .NET library (lifeme2027/NKaspa), not an official Kaspa SDK. Examples below use testnet-10 and read-only calls. Public resolvers and nodes are run by third parties and are not guaranteed to be available.

If you open the Kaspa integration docs as a C#/.NET developer, you will see official SDKs for Rust, WASM, and Python—and no official C# client. The usual fallback is to pull Kaspa's .proto definitions and generate a gRPC client yourself.

NKaspa takes a different route: it speaks Kaspa wRPC (JSON and Borsh over WebSocket) and does not include a gRPC client at all. In fact, passing a Kaspa gRPC port (16110, 16210, 16510, or 16610) to KaspaRpcClient.Create immediately throws ArgumentException.

Here is why NKaspa made that trade-off, how the wRPC client works in 0.1.11-alpha, and when you should still reach for gRPC.

1. Zero gRPC / Protobuf Toolchain Overhead

Generating and maintaining a Kaspa gRPC client in .NET pulls in Grpc.Net.Client, Google.Protobuf, and Grpc.Tools, plus a build-time .proto sync pipeline whenever rusty-kaspa changes its protobuf schemas.

NKaspa targets both net8.0 and netstandard2.1 with only two NuGet dependencies in src/NKaspa/NKaspa.csproj:

  • NBitcoin.Secp256k1 (3.1.6) for secp256k1 / Schnorr / ECDSA cryptography
  • System.Text.Json (8.0.5) for JSON serialization

Everything in NKaspa.RPC runs directly on .NET's built-in ClientWebSocket (and HttpClient for KaspaResolver). There is no protobuf code-gen step and no native gRPC transport dependency to bundle across desktop, server, or netstandard2.1 consumers.

2. Public Nodes and Resolvers Speak wRPC Over TLS

In the rusty-kaspa ecosystem, public community endpoints are commonly exposed behind TLS reverse proxies on port 443 via wRPC WebSocket paths (such as /kaspa/testnet-10/wrpc/json or /kaspa/testnet-10/wrpc/borsh) and discovered through the public wRPC resolver network (GET /v2/kaspa/{network}/{tls|any}/wrpc/{json|borsh}).

NKaspa's KaspaResolver (0.1.11-alpha) implements that resolver lookup directly:

  • Queries the 16 public resolver URLs from rusty-kaspa's Resolvers.toml in shuffled order (default 5-second timeout per resolver).
  • Falls back to DefaultFallbackEndpoints if every resolver fails (wss://eva.kaspa.green on mainnet; wss://vector-10.kaspa.green and wss://muon-10.kaspa.blue on testnet-10), or throws KaspaResolverException if you pass an empty fallback list to disable fallbacks.

That means a .NET app or wallet prototype can connect to a testnet-10 node without requiring the user to run a local gRPC node first—while still letting you point directly at your own ws:// or wss:// node URL when you run kaspad yourself.

3. JSON and Borsh Coexist Behind One Interface

Both KaspaWrpcJsonClient and KaspaWrpcBorshClient implement IKaspaRpcClient, covering the same wallet and node operations (EnsureReadyAsync, GetServerInfoAsync, GetBlockDagInfoAsync, GetSinkBlueScoreAsync, GetVirtualChainFromBlockAsync, GetUtxosByAddressesAsync, GetBalanceByAddressAsync, GetBalancesByAddressesAsync, SubmitTransactionAsync, GetFeeEstimateAsync, GetBlockAsync, and push subscriptions NotifyUtxosChangedAsync, NotifyVirtualDaaScoreChangedAsync, NotifyBlockAddedAsync).

You pick an encoding per connection via KaspaRpcClient.Create(url, KaspaRpcEncoding.Auto, options):

Network gRPC (rejected) wRPC Borsh wRPC JSON
Mainnet 16110 17110 18110
Testnet 16210 17210 18210
Simnet 16510 17510 18510
Devnet 16610 17610 18610

How KaspaRpcEncoding.Auto resolves a URL:

  1. gRPC ports always fail fast: 16110, 16210, 16510, and 16610 throw ArgumentException, even if you explicitly pass KaspaRpcEncoding.Json or KaspaRpcEncoding.Borsh.
  2. URL path wins over port: a path ending in /wrpc/borsh or containing /borsh selects Borsh; a path ending in /wrpc/json or containing /json selects JSON.
  3. No silent guessing on port 443: if both the path and the port are ambiguous (for example, wss://example.com on port 443 with no /json or /borsh segment), Create throws ArgumentException instead of silently picking one.
  4. Wire-level mismatch fails fast: if a JSON client receives a binary WebSocket frame, or a Borsh client receives a text frame (such as a JSON handshake), NKaspa immediately fails pending calls with KaspaRpcEncodingMismatchException instead of hanging until RequestTimeout or looping reconnects.

4. Read-Only Testnet-10 Example (0.1.11-alpha)

Install the prerelease package:

dotnet add package NKaspa --version 0.1.11-alpha 

Connect to a testnet-10 node, verify network/sync/UTXO-index readiness, and read DAG info:

using NKaspa; using NKaspa.RPC; var options = new KaspaWebSocketOptions { ConnectTimeout = TimeSpan.FromSeconds(15), RequestTimeout = TimeSpan.FromSeconds(30), MaxMessageBytes = 16 * 1024 * 1024, // 16 MiB default cap AutoReconnect = false // opt-in; off by default }; // Direct URL (path selects JSON; swap to /wrpc/borsh for Borsh) await using var rpc = KaspaRpcClient.Create( "wss://vector-10.kaspa.green/kaspa/testnet-10/wrpc/json", KaspaRpcEncoding.Auto, options); try { await rpc.ConnectAsync(); // Fails with typed KaspaWrpcException subclasses if the node is on // the wrong network, not synced, or missing --utxoindex. await rpc.EnsureReadyAsync(Network.Testnet, requireSynced: true, requireUtxoIndex: true); var info = await rpc.GetServerInfoAsync(); var dag = await rpc.GetBlockDagInfoAsync(); Console.WriteLine($"Node {info.ServerVersion} on {info.NetworkId}, virtual DAA score: {dag.VirtualDaaScore}"); } catch (KaspaWrongNetworkException ex) { Console.Error.WriteLine($"Wrong network: expected {ex.ExpectedNetwork}, node reported {ex.ReportedNetworkId}"); } catch (KaspaNodeNotSyncedException) { Console.Error.WriteLine("Node is not synced yet."); } catch (KaspaUtxoIndexNotEnabledException) { Console.Error.WriteLine("Start kaspad with --utxoindex for address/UTXO queries."); } catch (KaspaNodeUnreachableException ex) { Console.Error.WriteLine($"Node unreachable: {ex.Message}"); } 

If you prefer automatic public-node discovery over a hardcoded URL, KaspaResolver wraps the same connection type:

var resolver = new KaspaResolver(transport: KaspaResolverTransport.Tls); await using var rpc = await resolver.ConnectAsync(Network.Testnet, KaspaRpcEncoding.Json); await rpc.EnsureReadyAsync(Network.Testnet); 

5. When You Should Still Use gRPC (and Current Alpha Limits)

wRPC is not a drop-in replacement for every Kaspa workflow. Be aware of what NKaspa intentionally leaves out or has not implemented yet:

  • No gRPC support: If your infrastructure only exposes kaspad's gRPC port (16110/16210) or you need gRPC-only admin/mining RPCs not covered by IKaspaRpcClient, generate a client from the official rusty-kaspa .proto files instead.
  • Alpha & unaudited: 0.1.11-alpha is for experimentation and testnet development, not audited production custody.
  • Unimplemented features: Full block types are not implemented. BN254 pairing and RISC0 STARK verification are not implemented (OP_ZKPRECOMPILE only checks tag, cost, and layout and does not push true), so do not expect ZK covenant verification in NKaspa.
  • Safe reconnect defaults: AutoReconnect defaults to false; even when enabled, in-flight requests fail rather than being silently resent (so a SubmitTransactionAsync call is never blindly replayed by the transport layer).

Links