plugins/compact-core/skills/contract-patterns/SKILL.md
Use when implementing common Compact contract patterns such as voting systems, escrow, token transfers, access control, auctions, registries, or when looking for reusable contract templates and design patterns for Midnight blockchain development.
npx skillsauth add aaronbassett/midnight-knowledgebase compact-core:contract-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reusable Compact contract patterns and best practices for Midnight development
This skill provides a comprehensive catalog of Compact contract patterns for the Midnight blockchain. Patterns range from simple building blocks to comprehensive multi-contract systems.
Simple Patterns (~10 focused examples)
Deep-Dive Implementations (3 comprehensive systems)
| Pattern | File | Use Case |
|---------|------|----------|
| Counter | examples/simple/counter.compact | Basic state increments |
| Ownership | examples/simple/ownership.compact | Single-owner control |
| Time Lock | examples/simple/time-lock.compact | Delayed execution |
| Whitelist | examples/simple/whitelist.compact | Membership verification |
| Rate Limit | examples/simple/rate-limit.compact | Action throttling |
| Multi-Sig | examples/simple/multi-sig.compact | N-of-M approvals |
| Pausable | examples/simple/pausable.compact | Emergency stops |
| Upgradeable | examples/simple/upgradeable.compact | Logic migration |
| Fee Collector | examples/simple/fee-collector.compact | Payment handling |
| Random Selection | examples/simple/random-selection.compact | Commit-reveal randomness |
| System | Directory | Description |
|--------|-----------|-------------|
| Private Voting | examples/deep-dives/private-voting/ | Complete anonymous voting with ZK proofs |
| Token Escrow | examples/deep-dives/token-escrow/ | Multi-party custody with conditions |
| Access Registry | examples/deep-dives/access-registry/ | Role-based access with Merkle proofs |
"Show me the counter pattern"
→ Read examples/simple/counter.compact
"How do I implement private voting?"
→ Read references/private-voting.md then explore examples/deep-dives/private-voting/
"I need time-locked multi-sig"
→ Combine time-lock.compact + multi-sig.compact patterns
All patterns use standard library imports:
import CompactStandardLibrary;
Some advanced patterns may require additional imports:
import CompactStandardLibrary.Merkle;
import CompactStandardLibrary.Crypto;
tools
Use when setting up Midnight development environment, installing Compact compiler and developer tools, configuring proof server, verifying prerequisites, or getting started with Midnight development.
tools
--- name: midnight-tooling:midnight-debugging description: Use when encountering Midnight errors like "compact: command not found", "ERR_UNSUPPORTED_DIR_IMPORT", version mismatches, proof server failures, "@midnight-ntwrk" package errors, or compilation failures. --- # Midnight Environment Debugging Expert knowledge for identifying and resolving common Midnight development toolchain issues. ## Diagnostic Approach When encountering Midnight-related errors, follow this systematic approach: 1.
tools
Use when checking Midnight version compatibility, understanding pragma language_version, verifying compiler and runtime version relationships, or troubleshooting version mismatch errors between Midnight components.
tools
Use when setting up CI/CD for Midnight projects, configuring GitHub Actions for Compact contract compilation, running TypeScript tests in CI, validating version consistency, or automating contract builds.