The Contract
View Contract Code
View Contract Code
How It Works
Pragma Directive
Import Statement
Opaque, Bytes, and stdlib functions.
Ledger Declaration
Opaque<"string"> stores a variable-length byte sequence whose value is opaque to the circuit (hashed inside ZK, full value visible off-chain).
Circuits (Functions)
circuit declares a function that compiles to a zero-knowledge circuit. export makes it callable from outside the contract. [] is the empty-tuple unit type — the circuit returns nothing.
The disclose() Function
Opaque<"string"> values are treated as witness-tainted: the compiler refuses to write them to the public ledger unless you explicitly disclose them. disclose(x) is a compiler annotation that says “I know this value flows from a private/witness source to a public location and that’s intentional.”
If you tried message = customMessage without disclose, the compiler would reject it with:
Every circuit parameter requires
disclose() when it flows directly into
a ledger write, regardless of its type. The compiler is conservative: it
doesn’t know whether a given call site supplies the parameter from a public
source or from witness data, so it forces you to declare the disclosure
explicitly at every ledger boundary.What’s Next
First App - Counter
Build an interactive counter with validation
Primitive Types
Learn about Compact’s type system