Learn Midnight's Compact language through practical examples. This project is built on the Midnight Network.
Visit https://compact-by-example.org. Inspired by Solidity by Example.
A community-driven collection of Compact smart contract examples for building privacy-preserving applications on Midnight Network. Each example is complete, tested, and ready to run.
Prerequisites:
- Node.js v20 LTS or higher
- npm or yarn
Installation:
# Clone the repository
git clone https://github.com/Olanetsoft/compact-by-example.git
cd compact-by-example
# Install dependencies
npm install
# Start the development server
npm run devVisit http://localhost:3000 to view the documentation locally.
To set up Compact itself (compiler, proof server, wallet), see setup.mdx.
compact-by-example/
├── basics/ # Fundamentals (hello-world, types, mappings, ...)
├── applications/ # Full token contracts (ERC20, ERC721, ERC1155)
├── .github/ # Issue templates, PR templates, CI/CD
├── images/ # Assets and graphics
├── logo/ # Brand assets
├── setup.mdx # Toolchain installation guide
├── docs.json # Mintlify configuration
└── index.mdx # Homepage
Help us build these sections:
- Privacy & ZK Proofs - Zero-knowledge circuits and private state
- Smart Contracts - Tokens, NFTs, and DAOs
- DeFi - Decentralized finance protocols
- Advanced Patterns - Complex contract architectures
- Security - Best practices and common vulnerabilities
We welcome contributions! Whether you're fixing a typo, improving documentation, or adding a new example.
How to contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-example) - Make your changes (follow our style guide)
- Test your code (
npm run dev) - Commit with clear messages (
git commit -m 'Add: your feature') - Push to your branch (
git push origin feature/your-example) - Open a Pull Request
Read our Contributing Guide for detailed instructions.
- Discord - Ask questions, share projects
- X (Twitter) - Latest updates
- YouTube - Video tutorials
- Midnight Documentation - Official docs
MIT - see LICENSE file for details.
Built by the Midnight community • Report Bug • Request Feature • Submit Example