Skip to main content

The Contract

How It Works

Unsigned Integer Types - Bounded

Uint<m..n> represents values from m to n (inclusive). Lower bound must be 0.

Unsigned Integer Types - Sized

Uint<n> uses up to n bits, equivalent to Uint<0..(2^n - 1)>. The maximum width is Uint<248>.

Field Type

Elements of the scalar prime field used by the ZK proof system. Arithmetic on Field wraps modulo the prime. Comparison operators (<, <=) are not defined on Field; convert to a Uint first if you need ordering.

Bytes Type

Fixed-length byte arrays. Bytes<n> for exactly n bytes.

Opaque Types

Opaque<"label"> is a value whose internal representation is opaque to circuit logic: the circuit can hash it, store it, pass it around, and compare it for equality (==, !=), but cannot do arithmetic on it or inspect individual bytes. The witness layer holds the real bytes; inside the circuit the value is represented by its hash.

Disclosure Rule for Circuit Parameters

Compact’s privacy model is conservative: any circuit parameter is treated as potentially witness-derived at compile time. Writing a parameter directly to ledger state without disclose() fails with:
This applies to every type — Uint, Field, Bytes, and Opaque alike. disclose(x) is a compiler annotation that says “I know this value flows from a (potentially) private source to a public location and that’s intentional.” See Privacy & Disclosure for more on the disclosure rule.

Arithmetic Widening and Casts

Compact has no silent overflow. Arithmetic on bounded integers produces a wider result type:
See Overflow Protection for the full pattern.

Boolean Type

Two values: true and false. Standard operators: &&, ||, !, ==, !=.

What’s Next

Hello World

Apply types in your first contract

First App

Build a counter with type safety