Skip to content

scalus3/validator.g8

Repository files navigation

Scalus $name;format="Camel"$ Smart Contract

A Scalus smart contract starter generated from the validator.g8 template.

$name;format="Camel"$.scala is a Plutus V3 validator scaffold: every script purpose (spend, mint, reward, certify, vote, propose) is stubbed and fails until you implement it. Fill in the bodies you need and remove the rest.

Prerequisites

Build & test

The project works with both Scala CLI and sbt.

With Scala CLI:

scala-cli test .
scala-cli compile .
scala-cli fmt .

With sbt:

sbt test
sbt compile

Test backends

$name;format="Camel"$Integration.test.scala runs against a backend selected by the SCALUS_TEST_ENV environment variable:

sbt test                       # in-memory emulator (default, fast)
SCALUS_TEST_ENV=yaci sbt test  # a local Yaci DevKit node (requires a running Docker daemon)

The same works with Scala CLI, e.g. SCALUS_TEST_ENV=yaci scala-cli test ..

Project layout

Both tools share the same flat source layout: sources live at the project root and test sources use the .test.scala suffix.

  • $name;format="Camel"$.scala — the on-chain validator
  • $name;format="Camel"$.test.scala — unit tests using scalus-testkit's ScalusTest
  • $name;format="Camel"$Integration.test.scala — submit-based tests (emulator / Yaci DevKit)
  • $name;format="Camel"$Contract.scala — the Contract (compiled script + CIP-57 blueprint)
  • project.scala — Scala CLI build configuration (Scala version, Scalus compiler plugin, deps)
  • build.sbt — sbt build configuration (same versions and deps)

Blueprint & deploy

The sbt build enables the scalus-sbt-plugin, which adds tasks backed by the Contract in $name;format="Camel"$Contract.scala:

# Generate a CIP-57 blueprint under target/.../META-INF/scalus/blueprints/
sbt blueprint

# Deploy the validator as a reference-script UTxO (needs a Blockfrost key and a funded wallet)
export BLOCKFROST_API_KEY=...        # or pass --blockfrost-key
export CARDANO_MNEMONIC="word1 ..."  # or pass --mnemonic
sbt "deploy $name;format="Camel"$Contract --network preview"

Profiling

Set SCALUS_PROFILE=1 to run the tests with on-chain execution profiling enabled. It writes an interactive HTML profile (CPU/memory per source line) to target/profile.html:

SCALUS_PROFILE=1 sbt test

The same works with Scala CLI, e.g. SCALUS_PROFILE=1 scala-cli test ..

Learn more

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages