Skip to main content

Scalus

Scalus is a development platform for building decentralized applications (DApps) on the Cardano blockchain. It provides a unified environment where developers can write both on-chain smart contracts and off-chain logic using Scala 3 - a modern, expressive, and type-safe functional programming language.

Meet Scalus

  • Write Cardano smart contracts in Scala 3 that compile to UPLC
  • Maintain fine-grained control over generated on-chain code with advanced optimisations
  • Build and evaluate transactions off-chain
  • Integrate on-chain and off-chain components in your full-stack application
  • Test your entire application with unit, integration, and property-based tests
  • Debug your solution on a testnet
  • Build and deploy production-ready application to mainnet
  • Enjoy a modern development experience with excellent IDE support, and the extensive Scala & JVM ecosystems.

Say goodbye to juggling multiple languages, libraries, and tools—meet Scalus, a development platform made for professionals and businesses who want to get things done.

Getting Started

This guide will help you set up your development environment and get your first Scalus Validator.

Install Scala on your computer

We recommend using Scala Installer - Coursier, that ensures that a JVM and standard Scala tools are installed on your system.

Homebrew based installation:

brew install coursier && coursier setup

Coursier will install Scala compiler, Command line tool: Scala CLI, Build tool: sbt, REPL: Ammonite and Code formatter: Scalafmt.

Get your first Scalus Validator

sbt new scalus3/hello.g8

This ran the template scalus3/hello.g8 using Giter8. Let's take a look at what just got generated:

validator/
├── HelloCardano.scala # Simple validator
├── HelloCardano.test.scala # Simple tests
├── project.scala # Project configuration
└── README.md

Test

Run unit tests (MUnit, ScalaTest and ScalaCheck):

scala-cli test hello

All is good if you see the following output:

validator.HelloCardanoSpec:
+ Hello Cardano 0.385s

Configure IDE

Setting up a productive development environment will significantly improve your Scala/Scalus development experience. Scala offers wide range of IDE support, the most popular are IntelliJ and VSCode.

  1. Install IntelliJ IDEA (Community or Ultimate edition) from the JetBrains website
  2. Install the Scala plugin:
    • Go to Settings/Preferences → Plugins → Marketplace
    • Search for "Scala" and install the plugin
    • Restart IntelliJ IDEA when prompted
  1. Open your Scalus project:
    • Select File → Open and navigate to your project directory
    • Choose Import as sbt project when prompted
import scalus.*
import scalus.builtin.Data
import scalus.ledger.api.v3.{PubKeyHash, TxInfo, TxOutRef}
import scalus.prelude.*
import scalus.prelude.Option.Some
import scalus.prelude.Prelude.*

/** This validator demonstrates two key validation checks:
* 1. It verifies that the transaction is signed by the owner's public key hash (stored in the datum)
* 2. It confirms that the redeemer contains the exact string "Hello, Cardano!"
*
* Both conditions must be met for the validator to approve spending the UTxO.
*/

@Compile
object HelloCardano extends Validator:
override def spend(
datum: Option[Data],
redeemer: Data,
tx: TxInfo,
sourceTxOutRef: TxOutRef
): Unit =
val Some(ownerData) = datum: @unchecked
val owner = ownerData.to[PubKeyHash]
val signed = tx.signatories.contains(owner)
require(signed, "Must be signed")
val saysHello = redeemer.to[String] == "Hello, Cardano!"
require(saysHello, "Invalid redeemer")

Support