# @midnightntwrk/wallet-sdk-shielded

> Manages shielded tokens on the Midnight network using zero-knowledge proofs.

Latest version **3.0.2** (published 2026-06-19) · Apache-2.0 license · 4.5K weekly downloads

## Install

```sh
npm install @midnightntwrk/wallet-sdk-shielded
pnpm add @midnightntwrk/wallet-sdk-shielded
yarn add @midnightntwrk/wallet-sdk-shielded
bun add @midnightntwrk/wallet-sdk-shielded
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-06-19 |
| First published | 2026-06-19 |
| Weekly downloads | 4.5K |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 115.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Midnight Foundation |
| Maintainers | ntwrk-bot |

## Links

- npm: https://www.npmjs.com/package/@midnightntwrk/wallet-sdk-shielded
- Repository: https://github.com/midnightntwrk/midnight-wallet
- Homepage: https://github.com/midnightntwrk/midnight-wallet#readme
- Issues: https://github.com/midnightntwrk/midnight-wallet/issues
- npm.io page: https://npm.io/package/@midnightntwrk/wallet-sdk-shielded

## Dependencies (9)

- [rxjs](https://npm.io/package/rxjs.md) ^7.8.2
- [effect](https://npm.io/package/effect.md) ^3.19.19
- [@midnight-ntwrk/ledger-v8](https://npm.io/package/@midnight-ntwrk/ledger-v8.md) ^8.1.0
- [@midnightntwrk/wallet-sdk-runtime](https://npm.io/package/@midnightntwrk/wallet-sdk-runtime.md) ^1.0.5
- [@midnightntwrk/wallet-sdk-utilities](https://npm.io/package/@midnightntwrk/wallet-sdk-utilities.md) ^1.2.0
- [@midnightntwrk/wallet-sdk-abstractions](https://npm.io/package/@midnightntwrk/wallet-sdk-abstractions.md) ^2.1.0
- [@midnightntwrk/wallet-sdk-capabilities](https://npm.io/package/@midnightntwrk/wallet-sdk-capabilities.md) ^3.3.1
- [@midnightntwrk/wallet-sdk-address-format](https://npm.io/package/@midnightntwrk/wallet-sdk-address-format.md) ^3.1.2
- [@midnightntwrk/wallet-sdk-indexer-client](https://npm.io/package/@midnightntwrk/wallet-sdk-indexer-client.md) ^1.2.3

## Recent versions

- 3.0.2 (latest) — 2026-06-19
- 4.0.0-canary.20261013150531-6289ea3 (canary) — 2026-10-13
- 3.1.0-canary.20261009161442-8f95733 (canary-v1) — 2026-10-09
- 4.0.0-rc.1 (rc) — 2026-10-07
- 4.0.0-canary.20261007114939-7ee351c (canary-v2) — 2026-10-07
- 4.0.0-beta.4 (beta) — 2026-09-24
- 4.0.0-canary.20261013132526-8a87477 — 2026-10-13
- 4.0.0-canary.20261012130426-60e35b6 — 2026-10-12
- 4.0.0-canary.20261006161905-56542fa — 2026-10-06
- 4.0.0-canary.20261006082857-3c6134f — 2026-10-06
- 3.1.0-canary.20261005170924-1c8b4e7 — 2026-10-05
- 3.1.0-canary.20260930095107-aae483d — 2026-09-30
- 3.1.0-canary.20260929170316-1583a02 — 2026-09-29
- 4.0.0-canary.20260928141213-d0f38b3 — 2026-09-28
- 4.0.0-rc.0 — 2026-09-24
- … 83 more at https://npm.io/package/@midnightntwrk/wallet-sdk-shielded/versions

## README

# @midnightntwrk/wallet-sdk-shielded

Manages shielded tokens on the Midnight network using zero-knowledge proofs.

## Installation

```bash
npm install @midnightntwrk/wallet-sdk-shielded
```

## Overview

The Shielded Wallet handles private token operations where transaction values and addresses are hidden from observers
while maintaining verifiability. It provides:

- Zero-knowledge proof generation
- Coin commitment tracking
- Encrypted output decryption
- Shielded transfer transactions
- Transaction balancing for shielded tokens

## Usage

### Starting the Wallet

```typescript
import { ShieldedWallet } from '@midnightntwrk/wallet-sdk-shielded';
import * as ledger from '@midnight-ntwrk/ledger-v7';
import { randomBytes } from 'node:crypto';

// Configuration for the wallet
const configuration = {
  networkId: 'preview',
  provingServerUrl: new URL('http://localhost:6300'),
  relayURL: new URL('ws://localhost:9944'),
  indexerClientConnection: {
    indexerHttpUrl: 'http://localhost:8088/api/v3/graphql',
    indexerWsUrl: 'ws://localhost:8088/api/v3/graphql/ws',
  },
};

// Create secret keys from a shielded seed
const seed = randomBytes(32);
const shieldedSecretKeys = ledger.ZswapSecretKeys.fromSeed(seed);

// Create and start the wallet
const shieldedWallet = ShieldedWallet(configuration).startWithSecretKeys(shieldedSecretKeys);

// Start syncing with the network
await shieldedWallet.start(shieldedSecretKeys);
```

### Alternative: Start with Seed Directly

```typescript
// Start directly with a shielded seed
const shieldedWallet = ShieldedWallet(configuration).startWithSeed(seed);
await shieldedWallet.start(ledger.ZswapSecretKeys.fromSeed(seed));
```

### Restoring from Serialized State

```typescript
// Restore a wallet from previously serialized state
const shieldedWallet = ShieldedWallet(configuration).restore(serializedState);
await shieldedWallet.start(shieldedSecretKeys);
```

### Observing State

```typescript
wallet.state.subscribe((state) => {
  console.log('Progress:', state.state.progress);
  console.log('Coins:', state.state.coins);
});
```

### Creating Transfer Transactions

```typescript
const tx = await wallet.transferTransaction(shieldedSecretKeys, [
  { type: 'NIGHT', receiverAddress: 'mn_shield-addr1...', amount: 1000n },
]);
```

### Balancing Transactions

```typescript
const balancingTx = await wallet.balanceTransaction(shieldedSecretKeys, transactionToBalance);
```

### Creating Swap Offers

```typescript
const swapTx = await wallet.initSwap(
  shieldedSecretKeys,
  { NIGHT: 500n }, // inputs
  [{ type: 'TOKEN_A', receiverAddress: shieldedAddress, amount: 100n }], // outputs
);
```

## Privacy Model

Shielded transactions use zero-knowledge proofs to hide:

- Transaction amounts
- Sender addresses
- Receiver addresses

While still proving:

- The sender has sufficient balance
- No tokens are created or destroyed
- The transaction is valid

## Exports

- `ShieldedWallet` - Main wallet class
- `ShieldedWalletState` - Wallet state type
- Version 1 exports via `@midnightntwrk/wallet-sdk-shielded/v1`

## License

Apache-2.0

---
_Source: https://npm.io/package/@midnightntwrk/wallet-sdk-shielded · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
