Dev.to
5/9/2026

Designing public vs. private state: what goes where and why
Short summary
Midnight smart contracts store data across three distinct layers: public ledger (on-chain and visible), private state (off-chain in wallets, hidden), and transaction transcripts (revealed by disclose() calls). A critical misconception: marking a field as non-exported doesn't make it private—both exported and non-exported ledger fields are on-chain and publicly readable. Use witness functions for private data; disclose() explicitly marks transitions to public state.
- •Three data layers in Midnight: public ledger (on-chain), private state (off-chain), transaction transcript (disclosed values)
- •Non-exported fields are still on-chain—export controls API visibility, not privacy
- •Use witness functions for private data; disclose() explicitly marks transitions to public state
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


