Skip to Content
Scalus Club is now open! Join us to get an early access to new features 🎉
DocumentationDesign Patterns

Cardano Smart Contract Design Patterns

Proven patterns for building efficient and secure Cardano smart contracts, implemented in Scalus.

Optimization Patterns

Reduce execution costs by delegating computation to single-execution endpoints:

  • Withdraw Zero — Delegate computation to staking scripts using the “withdraw zero trick”, reducing costs from O(N²) to O(N)
  • Transaction Level Minting — Couple spend and mint endpoints so spending validators stay minimal
  • Merkelized Validator — Read verified data from stake validator redeemers for efficient batch operations

Validation Patterns

  • Parameter Validation — Verify that script instances across a multi-script protocol are parameterized with expected values

Indexing Patterns

  • UTxO Indexer — Map inputs to outputs using pre-computed indices for O(1) on-chain verification

Data Structures

  • Linked List — Ordered and unordered linked lists using NFTs and datums for on-chain state management

Utilities

  • Validity Range — Normalize time ranges to simplify interval validation in your contracts

Resources

Last updated on