MASM Smart Contracts
This section is the practical guide to authoring Miden smart contracts directly in Miden Assembly (MASM) — the path Miden mainnet supports for production deployments today. The Rust SDK is in active development and will become the default authoring path once it ships v1; until then, MASM is what you ship with.
You're here because you want to deploy a contract to Miden mainnet. MASM is a small, stack-based assembly language — closer to assembly than Rust or Solidity, but it gives you direct, predictable control over the VM and is what the mainnet kernel verifies. The Reference → Miden VM → Assembly section is the full language reference; this section is the Builder-side cookbook for using it.
When to use MASM vs. the Rust SDK
| Concern | MASM | Rust SDK |
|---|---|---|
| Mainnet production | Supported today | In active development |
| Performance / cycle control | Direct control over emitted instructions | Compiles via Wasm → MASM; less predictable |
| Learning curve | Small instruction set, explicit stack semantics | Familiar Rust ergonomics |
| Miden Standards | Standards modules callable directly | Same standards via Rust bindings |
| Long-term direction | Long-lived for system-level / performance-critical code | Will become the default authoring path once mature |
For mainnet shipping today, the choice is straightforward: write MASM. Most production patterns — account components, note scripts, transaction scripts, P2ID and P2IDE flows, faucet policies — are already covered by Miden Standards, so most contracts compose existing standards rather than rolling everything from scratch.
Where the language reference lives
The full Miden Assembly reference — every instruction, the stack semantics, control flow, cryptographic operations, debugging instructions — lives in Reference → Miden VM → Assembly. Treat that as the dictionary. This Builder section is the cookbook: how to structure a project, conventions for accounts, notes, and transactions, deployment, testing, and debugging in the context of building a Miden app.
Guides
Follow the guides below to build, test, and debug MASM contracts. The examples use Rust host harnesses to assemble and execute MASM, with the execution boundaries stated in each guide.
Your first MASM project
Assemble and execute a standalone MASM program with a Rust host.
MASM account components
Build a reusable MASM component with named storage and execute its procedures in a signed transaction.
MASM Note Scripts
Read committed note storage, call an account component, and validate authenticated consumption with protocol v0.17.
MASM Transaction Scripts
Compile and execute a MASM transaction script with explicit arguments and expiry checks.
Testing MASM with MockChain
Execute MASM through the transaction kernel, commit local state changes, and test rejection paths with MockChain.
Debugging MASM
Reproduce MASM compilation and runtime failures, inspect source diagnostics and stack output, and verify repairs.
For Rust client orchestration and network submission of a MASM account, see Deploying a Counter Contract. The Miden Bank tutorial covers the broader transaction lifecycle with Rust guest contracts.
See also
- Miden Standards — reusable account components, standard notes, faucet policies, callable from MASM.
- Reference → Miden VM → Assembly — full language reference (instructions, stack semantics, control flow).
- Smart Contracts → Overview — execution model and lifecycle (the concepts apply regardless of authoring language).
- Tools → Playground — interactive browser-based MASM environment for quick experiments.