> For the complete documentation index, see [llms.txt](https://socious.gitbook.io/midnight-smart-contract-library/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://socious.gitbook.io/midnight-smart-contract-library/readme.md).

# Midnight Smart Contract Library: User Guide & Documentation

This library provides secure, open-source smart contract templates for the Midnight blockchain. These contracts leverage Midnight’s Compact language and Zero-Knowledge (ZK) capabilities to ensure data protection, compliance, and "rational privacy".

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><h4> 👬</h4></td><td><strong>Escrow</strong></td><td>Facilitates secure transactions by holding funds in a contract-controlled treasury until specific conditions are met</td><td><a href="/spaces/6zTrFNH3DaKYtzhtBGMj">/spaces/6zTrFNH3DaKYtzhtBGMj</a></td><td><a href="https://images.unsplash.com/photo-1521791136064-7986c2920216?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwxfHxwYXJ0bmVyc2hpcHxlbnwwfHx8fDE3NjUyNDQyNjJ8MA&#x26;ixlib=rb-4.1.0&#x26;q=85">https://images.unsplash.com/photo-1521791136064-7986c2920216?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwxfHxwYXJ0bmVyc2hpcHxlbnwwfHx8fDE3NjUyNDQyNjJ8MA&#x26;ixlib=rb-4.1.0&#x26;q=85</a></td></tr><tr><td><h4>🧑‍⚖️</h4></td><td><strong>Dispute Resolution</strong></td><td>A decentralized framework for resolving conflicts without revealing the identity of the judges.</td><td><a href="/spaces/xpoxm1DE9T3eDVVfs5L8/pages/p8cNO7HK8krS1hbwxsAy">/spaces/xpoxm1DE9T3eDVVfs5L8/pages/p8cNO7HK8krS1hbwxsAy</a></td><td><a href="https://images.unsplash.com/photo-1593115057322-e94b77572f20?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwxfHxqdWRnZXN8ZW58MHx8fHwxNzY1MjQ0MzAyfDA&#x26;ixlib=rb-4.1.0&#x26;q=85">https://images.unsplash.com/photo-1593115057322-e94b77572f20?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwxfHxqdWRnZXN8ZW58MHx8fHwxNzY1MjQ0MzAyfDA&#x26;ixlib=rb-4.1.0&#x26;q=85</a></td></tr><tr><td>💰</td><td><strong>Crowdfunding</strong></td><td>Enables decentralized fundraising</td><td><a href="/spaces/YDMDU0GfDJEh16R49B5U">/spaces/YDMDU0GfDJEh16R49B5U</a></td><td><a href="https://images.unsplash.com/photo-1674515489647-fd8f76b86f65?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwyfHxjcm93ZGZ1bmRpbmd8ZW58MHx8fHwxNzY1MjQ0MzIxfDA&#x26;ixlib=rb-4.1.0&#x26;q=85">https://images.unsplash.com/photo-1674515489647-fd8f76b86f65?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwyfHxjcm93ZGZ1bmRpbmd8ZW58MHx8fHwxNzY1MjQ0MzIxfDA&#x26;ixlib=rb-4.1.0&#x26;q=85</a></td></tr></tbody></table>

## Tips & Resources

#### **Optimizing for Midnight Tokenomics**

* **DUST vs. NIGHT:** You do not need to spend the governance token (`NIGHT`) to pay for transactions. Instead, holding `NIGHT` generates `DUST`, which is used as fuel.
* **Tip:** Ensure your contract wallet holds sufficient `NIGHT` or has a designated DUST provider to keep the contract operational without constant refinancing,.

#### **Handling Privacy (Z-Swap)**

* **Selective Disclosure:** The Escrow contract uses `disclose(coin)` to prove validity. Be aware that while the *graph* is hidden, disclosed values (like the escrow amount) are visible on the ledger. Use this for auditability but avoid disclosing PII (Personally Identifiable Information),.

#### **Useful Links**

* **GitHub Repository:** <https://github.com/socious-io/midnight-escrow/>
* Midnight Example dApp: <https://github.com/socious-io/midnight-escrow/tree/main/example-dapp>
* **Compact Language Docs:** <https://docs.midnight.network/develop/reference/compact>
* **Midnight Faucet:** <https://midnight.network/test-faucet>
