Agent skill
compact-core:language-reference
Use when writing Compact smart contracts and need reference for primitive types (Field, Boolean, Uint), composite types (struct, enum, Vector, Bytes), circuit/witness syntax, control flow (if/else, for loops, assert), or module system (import, include, export).
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/language-reference
SKILL.md
Compact Language Reference
Complete reference for the Compact smart contract language used on Midnight Network.
Quick Reference
Primitive Types
| Type | Description | Example |
|---|---|---|
Field |
ZK-native field element (~254 bits) | const f: Field = 42; |
Boolean |
True/false value | const b: Boolean = true; |
Uint<N> |
Unsigned integer (N bits, N ≤ 248) | const n: Uint<64> = 100; |
Composite Types
| Type | Description | Example |
|---|---|---|
Bytes<N> |
Fixed-size byte array | const h: Bytes<32> = ...; |
struct |
Named record type | struct Point { x: Field, y: Field } |
enum |
Tagged union | enum Maybe<T> { Some(T), None } |
Vector<T, N> |
Fixed-size array | const v: Vector<Field, 3> = [1, 2, 3]; |
Special Types
| Type | Description | Example |
|---|---|---|
Opaque<'string'> |
UTF-8 string from TypeScript | witness get_name(): Opaque<'string'>; |
Opaque<'Uint8Array'> |
Binary data from TypeScript | witness get_data(): Opaque<'Uint8Array'>; |
Circuit Syntax
// Public circuit callable from TypeScript
export circuit transfer(to: Bytes<32>, amount: Uint<64>): [] {
// Circuit body
}
// Private helper circuit
circuit helper(x: Field): Field {
return x * x;
}
Witness Syntax
// Declaration (implemented in TypeScript)
witness get_private_key(): Bytes<32>;
// Usage in circuit
export circuit sign(message: Bytes<32>): Bytes<64> {
const key = get_private_key();
// Use key...
}
Control Flow
// Conditional
if (condition) {
// then branch
} else {
// else branch
}
// Bounded loop (bounds must be compile-time constant)
for i in 0..10 {
// loop body
}
// Assertion
assert condition, "Error message";
Module System
// Import specific items
import { hash } from "CompactStandardLibrary";
// Include entire file
include "utils.compact";
// Export for external use
export circuit public_fn(): Field { ... }
References
For detailed documentation on each topic:
- Type System - Complete type reference with constraints
- Circuits - Circuit and witness patterns
- Control Flow - Conditionals, loops, assertions
- Modules - Import, include, export, COMPACT_PATH
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?