plugins/compact-core/skills/ledger-adts/SKILL.md
Use when working with Compact on-chain state management using ledger ADTs including Cell, Counter, Map, Set, List, MerkleTree, or HistoricMerkleTree, or when needing to understand which operations are available in Compact vs TypeScript.
npx skillsauth add aaronbassett/midnight-knowledgebase compact-core:ledger-adtsInstall 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.
Reference for Midnight's ledger abstract data types for on-chain state management.
| ADT | Purpose | Key Operations |
|-----|---------|----------------|
| Cell<T> | Single mutable value | read, write |
| Counter | Increment-only counter | increment, value |
| Map<K, V> | Key-value storage | lookup, insert, remove |
| Set<T> | Membership collection | member, insert, remove |
| List<T> | Ordered collection | append, nth, length |
| MerkleTree<T> | Membership proofs | insert, root, pathForLeaf |
| HistoricMerkleTree<T> | Historical roots | Same + resetHistory |
ledger counter: Counter;
export circuit increment(): Uint<64> {
counter.increment(1);
return counter.value();
}
ledger balances: Map<Bytes<32>, Uint<64>>;
export circuit get_balance(user: Bytes<32>): Uint<64> {
const result = balances.lookup(user);
return if result is Maybe::Some(balance) { balance } else { 0 };
}
ledger members: MerkleTree<Bytes<32>>;
export circuit prove_membership(
leaf: Bytes<32>,
path: Vector<Bytes<32>, 20>
): Boolean {
const computed_root = merkleTreePathRoot(leaf, path);
return computed_root == members.root();
}
Some ADT operations are only available in TypeScript:
| ADT | Compact | TypeScript Only |
|-----|---------|-----------------|
| Counter | value, increment | - |
| Map | lookup, insert, remove | entries, keys |
| Set | member, insert, remove | entries, size |
| List | nth, append | entries, length |
| MerkleTree | insert, root | pathForLeaf, iteration |
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.