compact-core:ledger-adts

Document Midnight ledger ADTs for on-chain state management in TypeScript contracts.

Updated Feb 5, 2026
One-click install
npx skills add https://github.com/aaronbassett/midnight-knowledgebase --skill compact-core-ledger-adts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compact-core:ledger-adts
Source: https://github.com/aaronbassett/midnight-knowledgebase/tree/main/plugins/compact-core/skills/ledger-adts
Command: npx skills add https://github.com/aaronbassett/midnight-knowledgebase --skill compact-core-ledger-adts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Ledger ADTs provide a structured, standards-based reference for on-chain state management in Midnight contracts, consolidating common data structures and their usage patterns in one place.

Core Features & Use Cases

  • Definition and declaration of standard ledger ADTs (Cell<T>, Counter, Map<K, V>, Set<T>, List<T>, MerkleTree<T>, HistoricMerkleTree<T>).
  • Illustrative operations and practical examples for common contract scenarios, including interoperability between Compact and TypeScript and guidance on their respective usage.
  • Best-practice patterns and design considerations for secure and efficient on-chain state management.

Quick Start

Create a contract with a simple Map or Counter and explore basic ADT operations to observe state changes.

Frequently Asked Questions about compact-core:ledger-adts

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

FAQPage Schema
What are the standard ledger ADTs available for on-chain state management in Midnight contracts?

Standard ledger ADTs for Midnight on-chain state management include Cell<T>, Counter, Map<K, V>, Set<T>, List<T>, MerkleTree<T>, and HistoricMerkleTree<T>. These structures provide standardized options for declaring and interacting with contract state.

How do I declare and use a Map or Counter for on-chain state in Compact?

You can declare a Map or Counter on-chain state in Compact by utilizing standard ledger ADTs, then executing basic operations to observe state changes. Practical examples demonstrate interoperability between Compact and TypeScript for real-world contract scenarios.

When should I use a MerkleTree versus a HistoricMerkleTree for on-chain state?

Use MerkleTree for standard on-chain state verification and HistoricMerkleTree when your contract requires tracking previous state versions. Both are provided as ledger ADTs to ensure secure and efficient on-chain state management.

Can I use TypeScript alongside Compact when managing ledger ADTs in Midnight contracts?

Yes, ledger ADTs support interoperability between Compact and TypeScript. The reference provides operating patterns and practical examples to ensure safe integration of TypeScript interplay within production contracts.

What are the best practices for secure on-chain state management with ledger ADTs?

Best practices for secure on-chain state management involve enforcing clear ledger ADT declarations, following Compact versus TypeScript usage guidelines, and applying standard design considerations for safe integration into production contracts.

Do I need specific dependencies to work with ledger ADTs in Midnight contracts?

No external dependencies are required to work with Midnight ledger ADTs. The reference provides authoritative guidance and usage patterns for implementing Cell, Counter, Map, Set, List, and MerkleTree structures directly.