askill
compact

compactSafety 90Repository

Write privacy-preserving smart contracts in Compact (Minokawa) for Midnight Network. Use when creating contracts, defining types, using standard library functions, or implementing ZK patterns. Triggers on Compact language, circuits, ledger state, hashing, or zero-knowledge contract questions.

0 stars
1.2k downloads
Updated 1/5/2026

Package Files

Loading files...
SKILL.md

Compact Smart Contracts

Compact (being renamed to Minokawa) is Midnight's domain-specific language for privacy-preserving smart contracts. Contracts compile to ZK-SNARKs, enabling selective disclosure of data.

Note: As of compiler v0.26.0, the language is being renamed from "Compact" to "Minokawa" under the Linux Foundation Decentralized Trust. The toolchain commands still use compact.

Quick Start

pragma language_version 0.18;

export ledger message: Opaque<"string">;

export circuit setMessage(input: Opaque<"string">): [] {
  message = disclose(input);  // Makes private input public
}

Contract Structure

Every Compact contract has three parts:

  1. Pragma - Language version (pragma language_version 0.18;)
  2. Ledger - On-chain state declarations
  3. Circuits - ZK-proven functions

Core Concepts

Privacy Model

LevelSyntaxVisibility
Privateconst x = input;Only prover
Discloseddisclose(value)Allowed to become public
Provendisclose(a >= b)Public boolean only
Witnesswitness f(...): T;Private, DApp-provided

Notes:

  • Circuit arguments and witness returns are treated as potentially private (“witness data”).
  • disclose(...) is a compiler acknowledgement: it does not itself publish anything, it just permits an expression to flow into public outputs (ledger writes / exported circuit returns / cross-contract comms).
  • Only Opaque<"string"> and Opaque<"Uint8Array"> are currently supported.

Ledger Types

ledger counter: Counter;           // Auto-incrementing
ledger balances: Map<Bytes<32>, Uint<64>>;  // Key-value
ledger members: Set<Field>;        // Membership tracking
ledger tree: MerkleTree<20, Field>;  // Cryptographic proofs

Reference Files

TopicResource
Type Systemreferences/types.md - Full type reference
Standard Libraryreferences/stdlib.md - Hashing, coins, EC ops
VS Code extensionreferences/vscode-extension.md - Editor setup and tasks
Ledger Patternsreferences/ledger-patterns.md - State management
Advanced Patternsreferences/advanced-patterns.md - Access control, state machines
Detailed API Patternsreferences/detailed-api-patterns.md - API, code

Templates

TemplateDescription
assets/basic-contract.compactSimple ledger + circuit
assets/token-contract.compactToken with transfers
assets/private-voting.compactAnonymous voting
assets/commitment-reveal.compactCommit-reveal pattern

Compilation

# Compile contract
compact compile contracts/my-contract.compact contracts/managed/my-contract

# Output structure
contracts/managed/my-contract/
├── contract/    # JSON artifacts
├── keys/        # ZK proving/verifying keys
└── zkir/        # ZK Intermediate Representation

Common Errors

ErrorCauseFix
Type mismatchWrong bit widthUse correct Uint<N> size
Cannot assign private to publicMissing discloseAdd disclose() wrapper
Undefined symbolImport missingCheck pragma and imports

Best Practices

  • ✅ Start with pragma language_version 0.18;
  • ✅ Use witness for private inputs that need proofs
  • ✅ Choose smallest Uint<N> that fits your data
  • ✅ Use persistentHash for on-chain data, transientHash for temp
  • ❌ Don't expose secrets via disclose() unnecessarily
  • ❌ Avoid large state (increases gas costs)

Resources

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

84/100Analyzed 2/19/2026

High-quality technical reference skill for Midnight Network's Compact (Minokawa) privacy-preserving smart contract language. Well-structured with quick start, core concepts, privacy model explanation, reference files, templates, compilation steps, error table, and best practices. Excellent metadata with version 0.18 and author. Strong reusability via multiple contract templates and organized reference structure. Minor gaps in step-by-step actionable tutorials. Score benefits from clear trigger conditions, structured content, and comprehensive technical depth.

90
84
88
82
78

Metadata

Licenseunknown
Version-
Updated1/5/2026
PublisherFractionEstate

Tags

apigithub