Dev.to
7/1/2026

The original title is "Shielded Token Contracts on Midnight: Real Errors, Real Fixes"
Original: Shielded Token Contracts on Midnight: Real Errors, Real Fixes
Short summary
Working with shielded fungible tokens on Midnight requires understanding the Zswap protocol and the interplay between circuit logic and wallet-provided cryptographic proofs. Common errors include creating separate ledger fields for each asset type (instead use one Map keyed by token color) and attempting to both receive and send shielded tokens from the same ledger field in a single circuit. The author shares battle-tested patterns from months of DeFi development on Midnight.
- •Midnight's Zswap protocol requires wallet-generated proofs; circuits handle contract-side logic only
- •Use one Map for all shielded custody, keyed by token color, instead of separate ledger fields
- •Never mix receive and send operations on the same token in a single circuit
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


