- βοΈ Project Overview
- βοΈ Environment Setup
- π Directory Structure
- π οΈ Installation & Build
- π¬ Testing
- π§ͺ Property-Based Testing
- π Usage
- π Glossary
This repository contains a Plutus-based Auction Validator smart contract along with tooling to generate Blueprints and comprehensive test suites. It is part of the Plinth Template for teaching on-chain development on Cardano.
Follow these steps to prepare your environment:
# 1. Enter the Nix shell (requires Nix installed)
nix-shell
# 2. Update Cabal package index
cabal update
# 3. Ensure project dependencies are available
cabal build --enable-testsNote: If you do not use Nix, skip the
nix-shellstep and ensure you have GHC and Cabal installed via the Haskell Platform.
auction/ # Project root
βββ app/ # Executables for Blueprint generation
β βββ GenAuctionValidatorBlueprint.hs
β βββ GenMintingPolicyBlueprint.hs
βββ src/ # On-chain library modules
β βββ AuctionValidator.hs
βββ test/ # Test suite files
β βββ AuctionValidatorSpec.hs # Unit tests
β βββ AuctionMintingPolicySpec.hs # Minting policy tests
β βββ AuctionValidatorProperties.hs # QuickCheck properties
βββ default.nix # Nix definition (if applicable)
βββ shell.nix # Nix shell entry (if applicable)
βββ auction.cabal # Cabal project configuration
βββ cabal.project # Root project settings
βββ cabal.project.local # Local overrides (e.g., tests: True)
-
Enter Nix shell (optional):
nix-shell
-
Update Cabal index:
cabal update
-
Install dependencies & build:
cabal build --enable-tests
-
Generate Blueprints:
cabal run gen-auction-validator-blueprint -- ./blueprint-auction.json cabal run gen-minting-policy-blueprint -- ./blueprint-minting.json
cabal test auction-testscabal testauction-tests: Unit tests for the Auction Validator.minting-tests: Unit tests for the Minting Policy (if configured).
To verify invariants using QuickCheck:
-
Add a QuickCheck test suite entry in your
.cabal:test-suite auction-properties type: exitcode-stdio-1.0 main-is: AuctionValidatorProperties.hs hs-source-dirs: test build-depends: base >=4.7 && <5, , scripts, , QuickCheck, , plutus-ledger-api, , plutus-tx, , test-framework default-language: Haskell2010
-
Run the property suite:
cabal test auction-properties
- Deploy your compiled Plutus script on a Cardano network by submitting the generated blueprint JSON via your deployment tooling.
- Customize
AuctionParams(seller, currency symbol, token name, minimum bid, end time) inGenAuctionValidatorBlueprint.hsbefore generating the blueprint. - Extend the contract logic in
src/AuctionValidator.hsand re-run tests to ensure correctness.
| Term | Description |
|---|---|
| Cabal | Haskellβs package manager and build tool. |
| GHC | The Glasgow Haskell Compiler. |
| Plutus | Cardanoβs on-chain smart contract platform. |
| TxInfo | Metadata about a transaction passed to a Plutus validator. |
| ScriptContext | Context for script execution, including TxInfo and ScriptPurpose. |
| AssocMap | Plutusβs internal map type for associating keys to values (e.g., Datum, Redeemer). |
| hspec | A behavior-driven testing framework for Haskell. |
| QuickCheck | A property-based testing library for Haskell. |
| Blueprint | JSON representation of a Plutus script and its parameters, for off-chain tooling. |
Updated by Coxygen Global - Bernard Sibanda Date: 15 September 2025


