Write, compile and deploy Compact contracts from your browser.
CompactLab is a free IDE for Midnight. It compiles your contract on our servers; you deploy and call it from your own 1AM wallet. There is nothing to install.
Compact 0.31.1 · Midnight Preprod and Preview · MIT licensed
Explorer
pragma language_version >= 0.23; import CompactStandardLibrary; // On-chain counter using Midnight's built-in Counter type.export ledger round: Counter; constructor() { // Counter initialises to 0 automatically.} // Add 1 to the counter.export circuit increment(): [] { round.increment(1);} // Add a custom amount passed as a circuit parameter.export circuit incrementBy(amount: Uint<16>): [] { round.increment(disclose(amount));}Compile
Full Compact compile OK
compact 0.31.1
Circuits
2
Warnings
0
Circuits
The whole loop in one tab
Write, compile, deploy, call and read state on Midnight’s test networks, without leaving the browser.
An editor that knows Compact
Syntax highlighting, completions, hover types and inline diagnostics. Projects can hold several files, are saved to your account, and export as a zip.
Compile on our servers
Typecheck only for a quick check, or a full ZK build that produces the proving keys Deploy needs. No local toolchain.
Deploy and call from your wallet
1AM builds the proofs and signs in your browser, and fees come from your own tDUST. CompactLab never holds your keys or sends a transaction for you.
Read ledger state
Public ledger values update after every call. Preprod reads go through CompactLab or your own free Blockfrost key; Preview uses Midnight’s public indexer.
See what stays private
The Privacy view marks private, public, disclosed and hashed values, so you can see where disclose() is needed. It’s a guide, not a formal verifier.
Templates and lessons
Ten templates, from Hello World to escrow and commit-reveal. Hello World and Counter deploy without compiling. The Learn panel explains each concept.
From template to Preprod in three steps
You need a free CompactLab account to save and compile, and the 1AM wallet with test tokens to deploy.
Step 1
Pick a template
Start from Counter, or any of the ten templates, and change it to suit.
template Counter
file contracts/counter.compact
Step 2
Compile
A full ZK build checks your contract and produces its circuits and proving keys.
Full Compact compile OK
compact 0.31.1 circuits 2
Step 3
Deploy and call
Approve in 1AM, then call circuits from the Contract panel and read the ledger.
increment() approved in 1AM
ledger round = 1
Pinned to Midnight’s support matrix
Every template is compiled against these versions before a release, so what works here works with the rest of the Midnight stack. Mainnet is not supported. See the support matrix.
- Compact compiler
- 0.31.1
- Language
- 0.23
- Ledger
- 8
- Midnight.js
- 4.1.1
- Networks
- Preprod, Preview
- Wallet
- 1AM
Questions
Anything else? Open an issue on GitHub.
Yes. Create a free account to save projects and compile. Network fees are paid in tDUST from your own wallet: get tNIGHT from the Preprod faucet and your wallet generates tDUST from it.
No. Deploy and Call always open your 1AM wallet, which builds the proof and signs in your browser. CompactLab never holds keys and never sends a transaction on your behalf.
Projects are saved to your CompactLab account so you can pick up on any device. To compile, the source is sent to the CompactLab API. You can export any project as a zip.
Nothing to write and compile. To deploy and call, install the 1AM wallet and switch it to Preprod or Preview.
Midnight Preprod (the default) and Preview. Contracts on one network aren’t visible on the other. Mainnet is not supported.
Yes. The playground is MIT-licensed and on GitHub. Issues and pull requests are welcome.
Sponsored fees on Preprod, a browser simulator and shareable test links are planned. They are not available yet. See the changelog.
Try it with the Counter template.
It takes a few minutes to have it running on Preprod.