Developers
Raw Messaging SDK

TypeScript SDK

@nymproject/sdk is the browser-side raw messaging SDK. It opens a Nym mixnet client in a Web Worker and exposes a message-passing API: send text or binary payloads to another Nym address, receive payloads via event subscriptions, optionally reply anonymously with SURBs.

┌──────────────────────────────────────────────────────────────┐
│  Your browser app (alice)                                    │
│       └─ Nym Mixnet Client (WASM, Web Worker)                │
│            └─ WebSocket to entry gateway                     │
│                 └─ Nym mixnet (entry → 3 mix layers → exit)  │
│                      └─ Peer MixnetClient (bob)              │
│                           └─ Your peer's app                 │
└──────────────────────────────────────────────────────────────┘

Both ends run a Nym client. Sphinx encryption protects every hop end-to-end; neither gateway nor any mix node can link sender to receiver. This is the end-to-end messaging path, where you control both sides.

If you need HTTP, DNS, or WebSocket connections through the mixnet to third-party services, this isn't the right SDK. Use mix-fetch, mix-dns, or mix-websocket, all built on mix-tunnel for IPR exit routing.

For background on Sphinx, the mixnet exit model, and what the exit gateway can see, see Exit security.

Packages

PackageVariantWhen to use
@nymproject/sdkESMModern project, configurable bundler. See Bundling.
@nymproject/sdk-full-fatESM, inlinedModern project, no bundler config available. Larger bundle.
@nymproject/sdk-commonjsCJSLegacy project, configurable bundler.
@nymproject/sdk-full-fat-commonjsCJS, inlinedLegacy project, no bundler config available. Larger bundle.
@nymproject/contract-clientsESMQuery and execute Nym smart contracts on the Nyx chain. Separate transport (CosmWasm RPC, not the mixnet). See Smart Contracts.
⚠️

The *-full-fat variants embed the WASM and Web Worker as Base64 in the JS bundle. Bundle size is large (tens of MB). Prefer a standard variant where bundler configuration is possible.

Quick start

import { createNymMixnetClient } from '@nymproject/sdk-full-fat';
 
const nym = await createNymMixnetClient();
 
nym.events.subscribeToTextMessageReceivedEvent((e) => {
  console.log('Received:', e.args.payload);
});
 
await nym.client.start({
  clientId: crypto.randomUUID(),
  nymApiUrl: 'https://validator.nymtech.net/api',
  forceTls: true,
});
 
await nym.client.send({
  payload: { message: 'hello mixnet', mimeType: 'text/plain' },
  recipient: nym.client.selfAddress(),
});

For the full walkthrough including SURB replies and disconnect, see Quick Start.

Smart contracts

@nymproject/contract-clients (opens in a new tab) provides query and signing clients for every Nym smart contract on the Nyx chain (Mixnet, Coconut DKG, Vesting, Service Provider Directory, and more). It uses CosmJS (opens in a new tab) and the Nyx RPC endpoint, not the mixnet, so payloads are not routed through Sphinx.

See Smart Contracts for query and execute examples, and Cosmos Kit for wallet integration.

Where to go next

Quick StartVanilla TypeScript walkthrough of the messaging API.
Smart ContractsQuery and execute Nym contracts via @nymproject/contract-clients.
Cosmos KitWallet connection (Keplr, Ledger, Wallet Connect) for Nyx.
BundlingWebpack and esbuild configurations for WASM + Web Workers.
TypeDoc ReferenceGenerated API reference for @nymproject/sdk.