/midnight-skills:example-private-party-dappfrom midnight-skills
Builds a private party RSVP dApp on Midnight Network where attendee identities stay private until unshielded NIGHT check-in crosses the privacy boundary. Covers Compact contract patterns, Next.js frontend, 1AM wallet integration, and indexer polling.
Ships in midnight-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A private party contract lets an organizer collect RSVPs while attendee identities stay private until guests check in and pay the entry fee in unshielded NIGHT. That payment is the privacy boundary — unshielded token flows are always public on Midnight.
Source of truth: templates/private-party-dapp/ is the complete, runnable project, and this skill is the walkthrough for it. Do not retype the files from this page: copy the template, then adapt it (§18). The contract is shown in full because it is the lesson; everything else is described here and read from the template.
Get the template:
git clone --depth 1 --filter=blob:none --sparse https://github.com/Kali-Decoder/Midnight-Skills.git
cd Midnight-Skills && git sparse-checkout set templates/private-party-dapp
cp -R templates/private-party-dapp ../my-party && cd ../my-party
npm install # postinstall also installs contract/
npm run compact # compact compile +0.36.1 → contract/src/managed/private-party
npm run sync:assets # copies compiler/ keys/ zkir/ to public/zk/private-party
npm run dev # http://localhost:3000, needs the 1AM wallet (Ledger 9 build) on preprod
Without a checkout, read any file at https://raw.githubusercontent.com/Kali-Decoder/Midnight-Skills/main/templates/private-party-dapp/<path>.
Official reference: github.com/midnightntwrk/example-private-party — Compact tutorial + vitest harness (yarn test:local on Docker devnet).
Two ways to use this skill:
private-party.compact circuit by circuit (§5) and let them type it, but still take the TypeScript and UI from the template.What the template contains (paths relative to templates/private-party-dapp/):
contract/: private-party.compact (no witnesses), barrel, compile scriptapp/party/PartyClient.tsx: Next.js client UI (organizer deploy/start/close/claim, attendee RSVP/check-in)lib/midnight.ts: wallet session and providers (canonical Ledger 9 session from references/midnight-session.md)lib/party.ts: deployParty, rsvp, startParty, checkIn, closeEntry, claimFees, fetchPartyStatelib/address.ts: Bech32m unshielded address → { bytes: Uint8Array } for UserAddress circuit argslib/secret.ts: generate and store 32-byte DApp secrets in localStoragescripts/sync-zk-assets.mjs: copies ZK proving assets into public/zk/private-party/Shared references (canonical provider + troubleshooting — do not duplicate in prompts):
references/gotchas.md — Ledger 9 errors (version mismatch, EraMismatchError, Blockfrost 410/403), ZK asset pathsreferences/versions.json — pinned @midnight-ntwrk/* versionsPrimary references:
example-locker-dapp/ / templates/locker-dapp/ — same Next.js + 1AM structureexample-payment-dapp/ — unshielded receiveUnshielded / sendUnshielded patternsexample-hello-world/ — vitest + Docker devnet test harness (test script provided in official repo)compact/ — disclose(), persistentCommit, persistentHash, Set, sealed ledger, enumssecurity/ — privacy boundary checklist, what becomes public and whentoken-transfers/ — unshielded NIGHT units (Stars), Bech32 address decodingKey architecture notes:
_secret → getDappPublicKey(_secret) compared to on-chain organizerUserAddress + secret committed via persistentCommit; only the hash is stored in hashedPartyGoerscheckIn calls receiveUnshielded(nativeToken(), entryFee) then checkedInParty.insert(disclose(address)) — guest address becomes publicclaimFees calls sendUnshielded(...) to organizer's UserAddressdisclose() is a developer assertion — it marks values safe for public domains; it does not perform the disclosure itselfpersistentCommit output is safe on ledger without disclose() — sufficiently random salt (_secret) requireddeployContract / findDeployedContract with providers typed to the contract (no as any)indexerPublicDataProvider(network.indexer); the old offset: null patch is obsolete on indexer 4.4.101Uint<16> on ledger but cast to Uint<128> for unshielded ops; 1 NIGHT = 1_000_000 Stars_secret in localStorage — losing it means losing auth for that roledappConnectorNetwork). The UI connects with wallet.connect('preprod') in app/party/PartyClient.tsx; change that one call to target preview, and set the wallet to the same network.When helping the user, follow this sequence:
private-party.compact (§5); npm run compact, then npm run sync:assetslib/midnight.ts as-is (§9)deployParty(session, partySize, entryFeeStars, organizerSecret)rsvp before the party startsstartParty (or the contract moves to READY when the list is full)checkIn and pay the entry fee (crosses the boundary)closeEntry if not everyone checked in (automatic when full)claimFees after doors closetemplates/private-party-dapp/
├── package.json # scripts: dev, build, compact, sync:assets
├── next.config.mjs # Node fallbacks, isomorphic-ws alias, WASM (§13)
├── tsconfig.json
├── lib/
│ ├── isomorphic-ws-fix.mjs
│ ├── midnight.ts # session, providers, hex helpers
│ ├── party.ts # deploy, circuits, decode state
│ ├── address.ts # Bech32m → UserAddress bytes
│ └── secret.ts # per-contract secrets in localStorage
├── app/
│ ├── layout.tsx
│ ├── page.tsx # loads PartyClient with ssr: false
│ └── party/
│ └── PartyClient.tsx # all wallet + contract UI (inline styles)
├── contract/
│ ├── package.json # compact script (toolchain pinned)
│ └── src/
│ ├── private-party.compact
│ ├── index.ts # barrel → managed/private-party
│ └── managed/private-party/ # compiler output (gitignored)
├── scripts/
│ └── sync-zk-assets.mjs
└── public/zk/private-party/ # synced compiler/ + keys/ + zkir/
Optional test harness (official repo — not in browser template):
example-private-party/
├── contract/private-party.compact
├── src/test/party.test.ts # vitest: Alice organizer, Bob/Claire guests
├── compose.yml # node + indexer + proof-server
└── package.json # yarn test:local
node --version # 22+ for vitest harness; 20+ for Next.js frontend
docker --version # optional local devnet tests
curl --proto '=https' --tlsv1.2 -sSf \
https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh
source $HOME/.local/bin/env
Browser: 1AM wallet on the network PartyClient.tsx connects to (preprod by default), funded with tNIGHT for entry fees.
Every file below lives in templates/private-party-dapp/.
| File | Role | Change it when |
|---|---|---|
package.json | Next.js app; dev, build (runs sync:assets first), compact, sync:assets; postinstall installs contract/ | Adding dependencies (versions from references/versions.json) |
contract/package.json | compact script: compact compile +0.36.1 src/private-party.compact src/managed/private-party | Renaming the contract |
contract/src/private-party.compact | The contract (§5) | Party rules change |
contract/src/index.ts | CompiledPrivatePartyContract (§6) | Renaming the contract, adding witnesses |
lib/midnight.ts | createConnectedSession, queryLatestState, detectWallet, hex helpers (§9) | Almost never |
lib/party.ts | Contract API and state decode (§10) | Circuits or ledger fields change |
lib/address.ts | bech32ToUserAddress (§7) | Never |
lib/secret.ts | generateSecret, saveSecret, loadSecret (§8) | Changing where secrets live |
app/party/PartyClient.tsx | All UI (§11) | UI changes, target network |
scripts/sync-zk-assets.mjs | ZK asset copy (§12) | Renaming the contract |
next.config.mjs | Webpack config (§13) | Never |
npm run compact
# → contract/src/managed/private-party/{compiler,contract,keys,zkir}/
npm run sync:assets
# → public/zk/private-party/
Expected circuits: rsvp, startParty, checkIn, closeEntry, claimFees.
contract/src/private-party.compactFull content: references/private-party-contract.md. It covers the full annotated private-party.compact contract. Open it when you reach this step.
contract/src/index.tsThe contract has no witnesses, so the barrel builds the compiled contract with vacant witnesses and points its assets at the browser ZK path:
import { CompiledContract } from '@midnight-ntwrk/compact-js';
import { Contract } from './managed/private-party/contract/index.js';
export const zkConfigPath = '/zk/private-party';
export type PartyPrivateState = Record<string, never>;
export type PrivatePartyContract = Contract<PartyPrivateState>;
export const CompiledPrivatePartyContract = CompiledContract.make<PrivatePartyContract>('private-party', Contract).pipe(
CompiledContract.withVacantWitnesses,
CompiledContract.withCompiledFileAssets(zkConfigPath),
);
Import CompiledContract from @midnight-ntwrk/compact-js, not compact-runtime. The barrel also re-exports Contract, ledger, pureCircuits and Ledger from the compiler output.
lib/address.tsDecode Bech32 unshielded addresses for UserAddress circuit args. The { bytes: Uint8Array } format is required for UserAddress — not for Bytes<32> args, which take a raw Uint8Array.
import { MidnightBech32m, UnshieldedAddress } from '@midnightntwrk/wallet-sdk-address-format';
export function bech32ToUserAddress(bech32: string, networkId: string): { bytes: Uint8Array } {
const parsed = MidnightBech32m.parse(bech32).decode(UnshieldedAddress, networkId);
return { bytes: new Uint8Array(parsed.data) };
}
lib/secret.tsgenerateSecret() returns 32 random bytes from crypto.getRandomValues. saveSecret(role, contractAddress, secret) and loadSecret(role, contractAddress) keep it in localStorage under private-party:<role>:<contractAddress>. Losing it means losing that role's authority over the contract; there is no on-chain recovery.
lib/midnight.tsThe canonical Ledger 9 browser session from references/midnight-session.md, identical across templates. Use it as-is:
createConnectedSession(api, '/zk/private-party') reads network and endpoints from the wallet (dappConnectorNetwork), builds the proof provider through the wallet, levelPrivateStateProvider, the plain indexerPublicDataProvider, and providers.configqueryLatestState decodes queryContractState with deserialize({ v9: ContractState })detectWallet() prefers 1AM, then any other injected Midnight walletdemoStoragePassword keeps the private-state password in localStorage; replace it for production (§18)lib/party.tsUses deployContract / findDeployedContract with providers typed to the contract. Source: templates/private-party-dapp/lib/party.ts.
| Function | Circuit / effect |
|---|---|
deployParty(session, partySize, entryFeeStars, organizerSecret) | Constructor args [BigInt(partySize), BigInt(entryFeeStars), organizerSecret]; returns the contract address |
rsvp(session, address, userAddress, attendeeSecret) | callTx.rsvp |
startParty(session, address, organizerSecret) | callTx.startParty |
checkIn(session, address, userAddress, attendeeSecret) | callTx.checkIn (pays the entry fee, address becomes public) |
closeEntry(session, address, organizerSecret) | callTx.closeEntry |
claimFees(session, address, organizerAddress, organizerSecret) | callTx.claimFees |
fetchPartyState / decodePartyState | partyState name, maxListSize, entryFee, rsvpCount, checkedInCount |
userAddressFromSession(session) | The connected wallet's UserAddress |
Key details:
Uint<16> args take BigInt(...), not plain numbers.Bytes<32> args (secrets) are raw Uint8Array, not wrapped in { bytes }. UserAddress args require the { bytes } wrapper.setSize() reads compiled Set ledger fields whether .size is a property or a method.app/party/PartyClient.tsxOne client component with a role picker (organizer or attendee), a party status panel, and a handler per circuit (onDeploy, onRsvp, onStartParty, onCheckIn, onCloseEntry, onClaimFees). It connects with wallet.connect('preprod'), stores secrets per contract address through lib/secret.ts, polls fetchPartyState, and explains the privacy boundary next to the check-in button. Styling is inline, with no CSS framework.
scripts/sync-zk-assets.mjsCopies contract/src/managed/private-party/{compiler,keys,zkir} into public/zk/private-party/. Without compiler/, proving fails with EraMismatchError: artifact-era-undeclared. npm run build runs it automatically.
Verify: http://localhost:3000/zk/private-party/keys/rsvp.prover returns 200.
next.config.mjsRequired. On the client build it sets webpack fallbacks fs, net, tls, child_process to false, aliases isomorphic-ws to lib/isomorphic-ws-fix.mjs, and enables asyncWebAssembly and topLevelAwait.
git clone [email protected]:midnightntwrk/example-private-party.git
cd example-private-party
yarn install
yarn compile
yarn env:up # Docker: node + indexer + proof-server
yarn test:local # vitest party.test.ts
Expected flow (11 tests):
checkedInCount * entryFeeRead /src/test/party.test.ts for MidnightJS provider patterns with FluentWalletBuilder.
1. npm install && npm run compact && npm run sync:assets
2. npm run dev
3. Organizer: Connect 1AM → Deploy (max 2 guests, fee 5 Stars) → copy contract address
4. Attendee (other browser/wallet): Connect → paste address → RSVP
5. Organizer: Start party (or wait until RSVP list full → READY)
6. Attendee: Check in (wallet pays 5 Stars unshielded — address now public on ledger)
7. Organizer: Close doors (if needed) → Claim fees to unshielded address
8. Poll indexer — verify checkedInCount and partyState transitions
| Symptom | Cause | Fix |
|---|---|---|
Organizer cannot RSVP | Organizer secret used for RSVP | Use separate attendee secret |
You are not on the list | Wrong secret or address at check-in | Same _secret + UserAddress as RSVP |
The party has already started | RSVP after startParty | RSVP only in NOT_STARTED |
Only the organizer can start | Wrong organizer secret | Reload from localStorage or redeploy |
Contract balance wrong | Fee mismatch or partial check-ins | Verify entryFee * checkedInCount |
Invalid character 'm' at position 0 | Bech32 passed as bytes | Use bech32ToUserAddress() |
Version mismatch: compiled code expects 0.21.0, runtime is 0.16.0 | Old runtime | [email protected] + compact compile +0.36.1 |
EraMismatchError: artifact-era-undeclared | public/zk/... lacks compiler/ | Re-run npm run sync:assets |
Indexer 410 ENDPOINT_DECOMMISSIONED | Hardcoded old preprod host | Endpoints come from the wallet (dappConnectorNetwork) |
| ZK 404 | Assets not synced | npm run sync:assets |
| Lost organizer secret | No recovery on-chain | Redeploy contract; store secret in localStorage |
CompiledContract.withVacantWitnesses TypeScript error | compact-runtime vs compact-js mismatch | Import CompiledContract from @midnight-ntwrk/compact-js (§6) |
ContractMaintenanceAuthority WASM identity error | Two different compact-runtime copies loaded | Check npm ls @midnight-ntwrk/compact-runtime; root and contract/ must resolve the same version |
bigint type mismatch on constructor args | Passed number where bigint expected | Wrap in BigInt(value) for Uint<16> fields |
Bytes<32> wrapped in { bytes: ... } mismatch | Confusing it with UserAddress | Raw Uint8Array for Bytes<32>; { bytes } only for UserAddress |
isomorphic-ws not found in webpack | Missing alias | next.config.mjs alias (§13) |
size() not a function on Set ledger fields | .size is a property in some SDK versions, method in others | setSize() helper handles both (§10) |
| Wallet rejects connection / wrong chain | App and wallet on different networks | wallet.connect(...) in PartyClient.tsx and the wallet setting must match |
templates/private-party-dapp/; do not retype itprivate-party.compact's five exported circuits unless the user's rules differ (§5)npm run compact, then npm run sync:assets to public/zk/private-party/CompiledContract.withVacantWitnesses from @midnight-ntwrk/compact-js, not compact-runtimelib/midnight.ts and next.config.mjs as shipped[BigInt(partySize), BigInt(entryFeeStars), rawUint8Array]wallet-sdk-address-formatlocalStorage per contract addresswallet.connect(...) network in PartyClient.tsx matches the target network before demoingtemplates/private-party-dapp/ and get the unchanged template working first.contract/src/private-party.compact. If you rename it, update the compact script in contract/package.json, the managed/<name> imports and zkConfigPath in contract/src/index.ts, ZK_PATH in lib/party.ts, and the folder in scripts/sync-zk-assets.mjs.withVacantWitnesses). If you add some, replace that with CompiledContract.withWitnesses(...), give PartyPrivateState real fields, and pass a real initialPrivateState in lib/party.ts.lib/party.ts (callTx.<circuit>(...)). Keep PARTY_STATE_NAMES in the same order as the contract's enum, and extend decodePartyState for new ledger fields..d.ts: Uint<n> → bigint, Bytes<32> → raw Uint8Array, UserAddress → { bytes } via bech32ToUserAddress.PartyClient.tsx, and change wallet.connect('preprod') if you target another network.lib/secret.ts keeps role secrets in localStorage, and demoStoragePassword in lib/midnight.ts does the same for the private-state password. Both are demo-grade; for production, back them up or derive them from wallet-held material.npm run compact && npm run sync:assets).references/versions.json.To keep attendees private through payment, rework checkIn to use shielded tokens instead of receiveUnshielded — see tutorial conclusion and token-transfers/ skill.
Add "copy invite link" with contract address query param; show public checkedInParty addresses after boundary crossed.
Port official party.test.ts into the template monorepo using example-hello-world/ Docker compose pattern.
| Next step | Skill |
|---|---|
| Wallet connect only | react-wallet-connector/ |
| Unshielded token flows | token-transfers/ |
| Payment vault pattern | example-payment-dapp/ |
| Privacy audit | security/ |
| Compact language reference | compact/ |
| Local vitest harness | example-hello-world/ |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub kali-decoder/midnight-skills --plugin midnight-skills43 skills in this plugin
/1am-walletIntegrate the 1AM wallet for dust-free contract deployment and transaction flow on Midnight Network. Use this skill whenever a user is building a Midnight Network dApp, connecting to the 1AM browser extension, deploying or calling a Compact contract, handling ZK proving, setting up providers, or asking about dust-free transaction flow. Also use it for indexer patching, private state providers, payload encryption, or any question involving window.midnight['1am']./android-example-votingBuild a voting/poll dApp on Midnight Network using the Kuira Android SDK — Compact smart contract with create/cast/close circuits, passkey-derived identity, embedded wallet, Compose UI, reactive ledger reads via observeLedger(), and on-device ZK proving. Use when building a poll or voting dApp targeting Android./ankr-midnightIntegrate Ankr as a Midnight Network RPC provider for testnet and mainnet. Covers creating an Ankr project, copying HTTPS/WSS endpoints with API key, wiring the node URL into midnight-js / multinetwork configs, and calling Midnight JSON-RPC methods (midnight_*, system_*, chain_*, state_*). Use when the user asks about Ankr + Midnight, Ankr.js for Midnight, Ankr RPC endpoint, or replacing public Midnight RPC with Ankr.
/compactWrite, reason about, and debug Compact smart contracts for the Midnight blockchain. Use this skill whenever a user asks about Compact syntax, ledger state, witnesses, circuits, disclosure, ZK patterns, data types, standard library functions, security patterns, nullifier design, Merkle trees, or anything related to writing .compact files. Also trigger for questions about compiling contracts, debugging circuit errors, choosing between ledger ADTs, and implementing privacy-preserving patterns like commitments, hash-based auth, and anonymous membership proofs./compact-language-engineeringBuild and maintain language tooling for Midnight's Compact language (parsers, grammars, syntax highlighters, formatters, linters, language servers, IntelliJ/Grammar-Kit plugins, tree-sitter grammars) without changing what the language accepts. Use this skill when a user asks to write or fix a Compact grammar, port the grammar to tree-sitter, Grammar-Kit, JFlex, ANTLR, Lezer, or TextMate, check operator precedence or associativity, track down parser ambiguities or nullable and left-recursive rules, generate parser regression tests, compare a third-party parser against the compiler, or build an LSP or editor extension for `.compact` files. Also use it for questions like "what tokens does Compact have", "is `/` or unary minus valid Compact", "why does my highlighter break on block comments", "tree-sitter-compact rejects valid code", or "how does the Nite language server get its diagnostics".
/dust-gas-sponsorshipLet one wallet pay Midnight transaction fees for another wallet's transaction, so users with zero DUST can transact from their first click. Use whenever a dApp onboards new users, offers a free tier, or covers usage for its users: the two-sided sponsorship flow (user proves and binds, sponsor adds DUST and submits), the sponsor service and its acceptance policy, sponsor economics and monitoring, and the hosted alternatives (NIGHTGATE, Capacity Exchange).Other plugins' skills for the same job