plugins/midnight-core-concepts/skills/data-models/SKILL.md
Use when asking about UTXO vs account models, ledger tokens, shielded/unshielded tokens, nullifiers, coins, balances, or choosing between token paradigms in Midnight.
npx skillsauth add aaronbassett/midnight-knowledgebase midnight-core-concepts:data-modelsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Midnight supports two distinct token paradigms: UTXO-based ledger tokens and account-based contract tokens. Choose based on privacy requirements and use case complexity.
| Requirement | Use UTXO (Ledger Tokens) | Use Account (Contract Tokens) | |-------------|--------------------------|-------------------------------| | Privacy critical | Yes - independent, shieldable | No - balances visible | | Parallel processing | Yes - no ordering deps | No - sequential nonce | | Simple transfers | Yes | Overkill | | Complex DeFi logic | Limited | Yes | | Gaming state machines | No | Yes | | Governance/delegation | No | Yes |
UTXO = Unspent Transaction Output. Each token is a discrete digital coin that must be spent entirely.
Creation → Existence → Consumption → Prevention of Reuse
Unlike Bitcoin's spent markers, Midnight uses nullifiers:
nullifier = Hash(UTXO_commitment, ownerSecret)
Privacy benefit: Nullifier reveals nothing about which UTXO was spent. The nullifier can be computed without exposing the original UTXO identity.
Each UTXO independently chooses privacy level:
// Receiving shielded tokens
receive coins: Coin[];
// Sending tokens (can be shielded or unshielded)
send value: QualifiedValue, to: Address;
Maintain address-to-balance mappings within Compact contracts. Similar to ERC-20.
| Aspect | Account Model Limitation | |--------|-------------------------| | Privacy | Every transaction visible forever | | Ordering | Nonce creates sequential dependency | | MEV | Mempool visibility enables front-running | | Scalability | Redundant computation on every node |
Midnight's ledger has two components:
Token types are 256-bit collision-resistant hashes:
// Issue custom token from contract
// Type = Hash(contractAddress, domainSeparator)
For detailed technical information:
references/utxo-mechanics.md - Complete UTXO lifecycle, nullifier computationreferences/ledger-structure.md - Zswap state internals, Merkle tree detailsWorking Compact patterns:
examples/token-handling.compact - Receiving and sending tokenstools
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.