/midnight-skills:midnight-storagefrom midnight-skills
Explains Midnight's on-chain storage stack: ParityDB key-value backend, Patricia-Merkle trie state commitments, twoxhash storage keys, and state transition persistence. Useful for understanding state proofs, database layout, or trie performance on Midnight nodes.
Ships in midnight-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Midnight is built on the Polkadot SDK (Substrate) and uses ParityDB as its default database backend.
flowchart TB
subgraph Runtime["Runtime execution"]
STF["State transition function (WASM)"]
PM["pallet-midnight + other pallets"]
end
subgraph Trie["State layer"]
MPT["Patricia-Merkle trie"]
T2H["twoxhash — storage key generation"]
MPT --- T2H
end
subgraph Persist["Persistence"]
PDB["ParityDB — key-value store"]
end
STF --> PM
PM --> MPT
MPT --> PDB
MPT --> Commit["State root commitment per block"]
ParityDB is a fast key-value store designed for blockchain workloads.
The trie is the underlying data structure for state commitments.
| Property | Benefit |
|---|---|
| Merkle structure | Tamper-evident state root per block |
| Inclusion proofs | Efficient verification of contract state, balances, etc. |
| Incremental updates | Only changed paths recomputed per block |
Canonical ledger state from runtime pallets (including pallet-midnight) is organized in this trie and persisted via ParityDB.
flowchart LR
BlockN["Block N state root"] --> Root["Trie root hash"]
Root --> Leaf1["Storage item A"]
Root --> Leaf2["Storage item B"]
Root --> Leaf3["Contract state …"]
Query["RPC / light client"] --> Proof["Merkle inclusion proof"]
Proof --> Leaf2
twoxhash generates storage keys within the trie.
| Aspect | Detail |
|---|---|
| Type | Non-cryptographic hash |
| Purpose | Fast internal key-value lookups |
| Properties | Speed, low collision rate |
| Not for | Security-sensitive hashing (use Blake2-256) |
twoxhash significantly improves trie performance for map lookups without the cost of cryptographic hashing on every key derivation.
See midnight-cryptography/ for the full hash/signature split.
Every block:
pallet-midnight).sequenceDiagram
participant RT as Runtime
participant Trie as Patricia-Merkle trie
participant PM as pallet-midnight
participant DB as ParityDB
RT->>Trie: Apply storage writes (twoxhash keys)
RT->>PM: Commit ledger state
Trie->>Trie: Compute new state root
PM->>DB: Persist ledger commitment
Trie->>DB: Persist trie nodes
| Access path | Use case |
|---|---|
state_getStorage (RPC) | Raw storage key reads |
midnight_contractState (RPC) | Contract-specific state |
| Indexer GraphQL | Application-friendly contract/event queries |
midnight-onchain-logic/ — what gets written to storagemidnight-cryptography/ — Blake2-256 vs twoxhashmidnight-rpc/ — reading state via JSON-RPCmidnight-transactions/ — how txs trigger storage updatesWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
midnight, substrate, paritydb, patricia-merkle-trie, state-commitments
43 skills in this plugin
/1am-walletIntegrate the 1AM wallet for dust-free contract deployment and transaction flow on Midnight Network. Use this skill whenever a user is building a Midnight Network dApp, connecting to the 1AM browser extension, deploying or calling a Compact contract, handling ZK proving, setting up providers, or asking about dust-free transaction flow. Also use it for indexer patching, private state providers, payload encryption, or any question involving window.midnight['1am']./android-example-votingBuild a voting/poll dApp on Midnight Network using the Kuira Android SDK — Compact smart contract with create/cast/close circuits, passkey-derived identity, embedded wallet, Compose UI, reactive ledger reads via observeLedger(), and on-device ZK proving. Use when building a poll or voting dApp targeting Android./npx claudepluginhub kali-decoder/midnight-skills --plugin midnight-skillsOther plugins' skills for the same job