compact-core:compact-structure

Scaffold Compact smart contracts with pragma, imports, ledger, and circuit declarations.

37|9|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/devrelaicom/midnight-expert --skill compact-core-compact-structure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compact-core:compact-structure
Source: https://github.com/devrelaicom/midnight-expert/tree/main/plugins/compact-core/skills/compact-structure
Command: npx skills add https://github.com/devrelaicom/midnight-expert --skill compact-core-compact-structure

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Helps developers write, structure, and review Compact smart contracts for the Midnight blockchain by codifying contract anatomy, pragma and import usage, ledger and witness declarations, constructors, circuits, and disclosure rules so contracts compile and integrate with ZK proving and off-chain provers.

Core Features & Use Cases

  • Contract Scaffolding: Clear ordering and examples for pragma, imports, custom types, ledger declarations (including sealed ledgers), witness declarations, constructors, helper circuits, and exported circuits.
  • Type and ADT Guidance: Explanations for primitives, collections, enums, structs, counters, maps, sets, lists, Merkle trees, and casting rules to prevent common type errors.
  • Safety & Patterns: Disclosure rules, common mistakes, commit-reveal, Merkle membership, authentication patterns, and guidance for pure circuits to meet ZK-proof and compilation constraints.

Quick Start

Ask the skill to scaffold a Compact contract with pragma, imports, ledger and witness declarations, a constructor, helper circuits, and exported transaction circuits.

Frequently Asked Questions about compact-core:compact-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Midnight Compact smart contract?

Compact contract structure requires pragma declarations, CompactStandardLibrary imports, custom types, ledger and witness declarations, a constructor, helper circuits, and exported transaction circuits in a specific order to compile correctly for ZK proving.

What are disclosure rules in Compact contracts?

Disclosure rules in Compact contracts determine what data is revealed versus kept private during ZK-proof generation. They govern how ledger states and witness data interact with off-chain provers and on-chain verification.

How do I declare sealed ledgers and witnesses in Compact?

Sealed ledgers and witnesses in Compact are declared after imports and custom types. Sealed ledgers protect state privacy, while witness declarations define the zero-knowledge proof inputs needed for circuit execution and validation.

What common compile-time mistakes should I avoid in Compact language development?

Common Compact compile-time mistakes include incorrect type casting, missing language-version pragmas, improper ADT references, and violating pure circuit constraints. Following proper contract anatomy and disclosure rules prevents these errors.

Can I use Merkle membership and commit-reveal patterns in Midnight Compact circuits?

Yes, Midnight Compact supports Merkle membership and commit-reveal patterns within circuits. These patterns use custom types, maps, and witness declarations to enable private authentication and zero-knowledge verification.

When do I need pure circuits in Compact contracts?

Pure circuits in Compact contracts are needed when circuits must meet ZK-proof constraints without modifying ledger state. They isolate computational logic for off-chain provers while maintaining disclosure rules and type safety.