You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Midnight Tutorial: Understanding Wallet Sync — Why Your Deploy Fails Before It Starts (Bounty #300)
Understanding Wallet Sync: Why Your Deploy Fails Before It Starts
You just wrote your first Midnight dApp. The code compiles, the proof server is running, you call balanceUnboundTransaction — and nothing happens. Or worse, you get a cryptic error about missing UTXOs. The problem isn't your contract. The problem is that your wallet hasn't synced.
This tutorial explains what wallet sync actually means on Midnight, why skipping it breaks everything, and the exact patterns to ensure your transactions always work.
Tutorial for bounty #311: How to wrap Midnight contract interactions in a Node.js REST API with proof generation, wallet sync, error handling, and connection resilience.
Integrating Midnight Proofs into an Existing Backend
The Challenge: Zero-Knowledge Proofs in a Server Environment
Midnight contracts produce zero-knowledge proofs — cryptographic attestations that a transaction is valid without revealing private data. These proofs are essential for Midnight's privacy model, but integrating proof generation into an existing Node.js backend introduces specific challenges:
Proof generation is CPU-intensive and can timeout under load
Wallet state must be synchronized before signing or submitting
Server processes manage long-lived connections to the indexer and proof server, unlike browser wallets
Error handling must account for proof failures, network interruptions, and state sync delays
Midnight Network Tutorial: DUST Sponsorship - How One Wallet Pays Fees for Another User's Transaction (Bounty #299)
DUST Sponsorship on Midnight: How One Wallet Pays Fees for Another
The Problem: Users Without DUST Can't Transact
Midnight's privacy model relies on DUST — a shielded network resource, not a token, that pays for transaction fees. Every transaction consumes DUST. But here's the catch: new users start with zero DUST, and generating it requires holding NIGHT tokens through a multi-day lifecycle.
This creates a cold-start problem. How does a brand-new user submit their first transaction if they don't have DUST to pay fees?
The answer is DUST sponsorship: one wallet (the sponsor) pays the DUST fees for another user's transaction. This tutorial shows you exactly how.
Midnight Tutorial: Concurrent Transactions & UTXO Race Conditions — Patterns for handling stale UTXO errors with sequential queues, wallet pools, retry logic, and hybrid approaches
Concurrent Transactions on Midnight: UTXO Race Conditions & Workarounds
The Problem: When Two Transactions Collide
You deploy your first Midnight dApp. Everything works in testing — single transactions sail through. Then you go live, and something strange happens: users report that transactions randomly fail with an error like "stale UTXO" or "UTXO already consumed." Not every time. Just sometimes. And only when multiple actions happen close together.
This is the UTXO race condition, and it catches almost every developer building on UTXO-based chains. If you come from Ethereum or Solana, where accounts have balances you just increment and decrement, the failure mode feels alien. On Midnight, the same wallet trying to send two transactions at the same time can break — and understanding why requires understanding how UTXOs actually work.
This tutorial explains the root cause, walks through concrete failure scenarios, and gives you three battle-tested patterns to handle concurrent transactions on Midnig
Testing Compact Contracts: Unit Tests, Assertions, and Local Simulation — Midnight Network Tutorial #312
Testing Compact Contracts: Unit Tests, Assertions, and Local Simulation
This tutorial walks through writing automated tests for Midnight Compact smart contracts. You'll learn two testing approaches — fast simulator tests that validate circuit logic locally, and integration tests that exercise full on-chain interactions against a local devnet — and set up a CI pipeline to run them automatically.
The companion code uses a simple Voting contract, but the patterns apply to any Compact contract.
Midnight Tutorial #310: Reading and Reacting to Contract State from a Frontend — Eclipse Bounty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Midnight Network Tutorial: Compliance Attestation System with Selective Disclosure (Bounty #315)
Building a Compliance Attestation System with Selective Disclosure
Midnight Network Tutorial — Eclipse Bounty #315
Imagine a user needs to prove they're over 21 — without revealing their exact age, name, or address. On transparent blockchains, this is impossible: you either share everything or nothing. Midnight's ZK architecture makes selective disclosure practical.
This tutorial builds a compliance attestation system where an authority commits to user properties (age, residency, certifications) via Merkle tree commitments, and users can selectively prove specific properties without revealing others. Domain-separated hashing ensures different properties can't be correlated.
Midnight Network bounty #306 — Tutorial: Time and Deadlines in Compact. Covers block time API, Uint<16> problem, Counter type, practical patterns (auction, escrow, multi-phase) with 6 code examples and 3 workaround strategies.
Time and Deadlines in Compact: Block Time, Counters & the Uint<16> Problem
A practical guide to writing time-based smart contracts on Midnight Network
Why This Matters
Most smart contracts need time. Auctions end at a deadline. Escrows expire if unclaimed. Games progress through rounds. On traditional chains, you read the current timestamp and compare. On Midnight, privacy changes everything — you can't simply read block.timestamp because that would leak information.