Agent skill
compact-core:ledger-adts
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.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ledger-adts
SKILL.md
Ledger ADTs
Reference for Midnight's ledger abstract data types for on-chain state management.
Available ADTs
| 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 |
Quick Examples
Counter
ledger counter: Counter;
export circuit increment(): Uint<64> {
counter.increment(1);
return counter.value();
}
Map
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 };
}
MerkleTree
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();
}
Compact vs TypeScript Operations
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 |
References
- Counter - Counter operations and patterns
- Collections - Map, Set, List operations
- Merkle Trees - MerkleTree and HistoricMerkleTree
- Kernel - Special kernel operations
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?