Menu

Post image 1
Post image 2
1 / 2
0

Contract-state accounting vs UTXO tokens: two models for onchain value on Midnight

DEV Community·Harrie·21 days ago
#JKg3wfZP
Reading 0:00
15s threshold

Midnight gives you two ways to represent value in a contract. Most tutorials pick one and move on. This one covers both: what the real compiler-verified API looks like, where each model breaks, and why the UTXO path has more gotchas than it appears. Short version: UTXO tokens for privacy and real transferability. Ledger-state accounting for queryable bookkeeping. Both, when your contract needs both. All three contracts here compile against the latest Compact compiler. Verified CI run: IamHarrie-Labs/compact-token-guide Two separate systems Midnight runs a public ledger and a shielded Zswap layer. Not two views of the same data. Genuinely separate systems with different guarantees. Counter and Map fields live on the public ledger. Every insert, every increment is readable by anyone watching the chain. You can query balances, enumerate holders, build conditional logic on accumulated state. You cannot hide amounts. Zswap is a zero-knowledge Merkle tree.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More