Demo · Preprod only · Wallet SDK

Programmatic DUST

A local, terminal-first walkthrough of the Midnight Foundation tutorial. It creates a wallet, prints the shielded / unshielded / dust addresses, waits for tNIGHT from the faucet, then explicitly registers NIGHT UTXOs for DUST generation — the same step Lace performs when you click Generate tDUST, but exposed through the wallet SDK.

run it
bun scripts/dust-demo-preprod.mjs

The script writes its scratch wallet to .midnight-wallet-preprod-demo.local (0600, gitignored) and polls the wallet state until spendable DUST coins appear.

what it does
  1. Creates or restores a hex wallet seed.
  2. Derives shielded, unshielded, and DUST addresses.
  3. Prompts you to fund the unshielded address with the preprod tNIGHT faucet.
  4. Registers NIGHT UTXOs for DUST generation to a target DUST address.
  5. Polls until state.dust.availableCoins.length >= 1 — the true spendable signal.
prerequisites
  • Bun runtime.
  • A local Midnight proof server on port 6300.
  • Preprod tNIGHT from the faucet to the unshielded address.
  • Patience — DUST generation can take 1–20 minutes.
why this exists

The deploy script for the Midnight Ledger demo assumes tDUST is already available. That usually happens inside Lace, but the docs also show how to do it entirely in code. This script mirrors that guide so you can automate the full flow from wallet creation to spendable DUST without leaving the terminal.

Preprod-specific gotchas (fresh-wallet sync stalls, DustSpendProcessed decode errors, DUST-regeneration concurrency caps): see known issues →