scalus.uplc

package scalus.uplc

Members list

Type members

Classlikes

case class BuiltinRuntime(typeScheme: TypeScheme, f: (Logger, Seq[CekValue]) => CekValue, args: Seq[CekValue], costFunction: CostingFun)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
class CardanoBuiltins(builtinCostModel: BuiltinCostModel, platformSpecific: PlatformSpecific, semanticVariant: BuiltinSemanticsVariant)

Attributes

Supertypes
class Object
trait Matchable
class Any
trait Compiled[A]

A compiled Plutus script.

A compiled Plutus script.

This trait represents a script that has been compiled from Scala source code through the Scalus compiler pipeline (Scala -> SIR -> UPLC -> Plutus Script). It contains original Scala code, its type, scalus.compiler.sir.SIR, compiler options (backend etc), and generated UPLC program and serialized Plutus script.

Type parameters

A

the Scala type of the compiled code, typically a function type representing the validator signature

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CompiledPlutus[A]
class PlutusV1[A]
class PlutusV2[A]
class PlutusV3[A]
sealed abstract class CompiledPlutus[A](val lazyCode: () => A, val sir: SIR, val options: Options, val optimizer: Optimizer) extends Compiled[A]

Base implementation for compiled Plutus scripts of all versions.

Base implementation for compiled Plutus scripts of all versions.

This sealed abstract class provides the common implementation for compiling Scala code to Plutus scripts across all Plutus language versions (V1, V2, V3). Subclasses implement version-specific details such as program version numbers, script hash prefixes, and optimizer selection.

Type parameters

A

the Scala type of the compiled code

Value parameters

lazyCode

a thunk that evaluates to the original Scala code

optimizer

the UPLC optimizer to apply (version-specific)

options

compiler options controlling lowering and optimization

sir

the Scalus Intermediate Representation

Attributes

Supertypes
trait Compiled[A]
class Object
trait Matchable
class Any
Known subtypes
class PlutusV1[A]
class PlutusV2[A]
class PlutusV3[A]
sealed trait Constant

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Array
class Bool
class BuiltinValue
class ByteString
class Data
class Integer
class List
class Pair
class String
object Unit
Show all
object Constant

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Constant.type
object DeBruijn

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
DeBruijn.type
case class DeBruijnedProgram

A De Bruijn-indexed program.

A De Bruijn-indexed program.

A De Bruijn-indexed program is a versioned Term where the variables are indexed using De Bruijn indices. A program must be De Bruijn-indexed before it can be evaluated.

Value parameters

term

the term of the program

version

the version of the program

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
enum DefaultFun extends Enum[DefaultFun]

Plutus Core built-in functions.

Plutus Core built-in functions.

This enum defines all available built-in functions in Untyped Plutus Core (UPLC). Built-in functions provide primitive operations that cannot be expressed in the lambda calculus itself, such as arithmetic, cryptographic operations, and data structure manipulation.

==Plutus Version Compatibility==

Built-in functions are available in different Plutus versions:

  • '''Plutus V1''': Original set of builtins (integers, bytestrings, strings, Data, etc.)
  • '''Plutus V2''': Added SerialiseData
  • '''Plutus V3''': Added BLS12-381, bitwise operations, integer/bytestring conversions, additional hash functions (CIP-381, CIP-121, CIP-122, CIP-123, CIP-127)
  • '''Plutus V4''': Added array builtins, MaryEraValue builtins, DropList (CIP-153, CIP-156, CIP-158)

==Type Signatures==

Built-in functions have specific type signatures. Polymorphic builtins require explicit type instantiation via force before application.

==Categories==

The builtins are organized into the following categories:

  • '''Integer operations''': Arithmetic and comparison on arbitrary-precision integers
  • '''ByteString operations''': Manipulation of byte arrays
  • '''Cryptographic functions''': Hashing and signature verification
  • '''String operations''': UTF-8 string manipulation
  • '''Control flow''': Conditionals and unit handling
  • '''Pairs and Lists''': Data structure operations
  • '''Data type''': Operations on the universal Data type
  • '''BLS12-381''': Pairing-friendly elliptic curve operations (Plutus V3+)
  • '''Bitwise operations''': Bit-level manipulation of bytestrings (Plutus V3+)
  • '''Value operations''': Multi-asset value manipulation (Plutus V4+)

Attributes

See also
Companion
object
Supertypes
trait Enum
trait Product
trait Equals
class Enum[DefaultFun]
trait Serializable
trait Comparable[DefaultFun]
trait Constable
class Object
trait Matchable
class Any
Show all
object DefaultFun

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
DefaultFun.type
object DefaultFunOrdering extends Ordering[DefaultFun]

Attributes

Supertypes
trait Ordering[DefaultFun]
trait PartialOrdering[DefaultFun]
trait Equiv[DefaultFun]
trait Serializable
trait Comparator[DefaultFun]
class Object
trait Matchable
class Any
Show all
Self type
sealed abstract class DefaultUni

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Apply
object BuiltinValue
object Data
class LiftedUni[A]
object Bool
object ByteString
object Integer
object String
object Unit
object ProtoArray
object ProtoList
object ProtoPair
Show all
object DefaultUni

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
DefaultUni.type
trait Delayed[+A]

Attributes

Supertypes
class Object
trait Matchable
class Any
case class Expr[+A](term: Term)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ExprBuilder

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Meaning

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Meaning.type
case class NamedDeBruijn(name: String, index: Int = ...)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait PlutusParams

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class PlutusV1[A] extends CompiledPlutus[A]

A compiled Plutus V1 script.

A compiled Plutus V1 script.

Plutus V1 was introduced in the Alonzo hard fork. It provides basic smart contract functionality with the original set of builtin functions.

Type parameters

A

the Scala type of the compiled code

Value parameters

lazyCode

a thunk that evaluates to the original Scala code

optimizer

the UPLC optimizer to apply (if optimization is enabled)

options

compiler options controlling lowering and optimization

sir

the Scalus Intermediate Representation

Attributes

Example
 given scalus.compiler.Options = scalus.compiler.Options.release
 val validator = PlutusV1.compile((datum: Data, redeemer: Data, ctx: Data) => ...)
 val scriptHash = validator.script.scriptHash
Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class CompiledPlutus[A]
trait Compiled[A]
class Object
trait Matchable
class Any
Show all
object PlutusV1

Factory methods for creating compiled Plutus V1 scripts.

Factory methods for creating compiled Plutus V1 scripts.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
PlutusV1.type

Plutus V1 cost model parameters.

Plutus V1 cost model parameters.

The names of the fields are taken from https://github.com/input-output-hk/plutus/blob/1.40.0.0/plutus-ledger-api/src/PlutusLedgerApi/V1/ParamName.hs and Blockfrost Protocol Parameters JSON uses these names as well in blockfrost-params-epoch-544.json

But what's really important is the order of the fields because that's the order of the parameters in the protocol parameters array.

Attributes

Companion
object
Supertypes
trait PlutusParams
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final case class PlutusV2[A] extends CompiledPlutus[A]

A compiled Plutus V2 script.

A compiled Plutus V2 script.

Plutus V2 was introduced in the Vasil hard fork. It adds reference inputs, inline datums, reference scripts, and the SerialiseData builtin.

Type parameters

A

the Scala type of the compiled code

Value parameters

lazyCode

a thunk that evaluates to the original Scala code

optimizer

the UPLC optimizer to apply (if optimization is enabled)

options

compiler options controlling lowering and optimization

sir

the Scalus Intermediate Representation

Attributes

Example
 given scalus.compiler.Options = scalus.compiler.Options.release
 val validator = PlutusV2.compile((datum: Data, redeemer: Data, ctx: Data) => ...)
 val scriptHash = validator.script.scriptHash
Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class CompiledPlutus[A]
trait Compiled[A]
class Object
trait Matchable
class Any
Show all
object PlutusV2

Factory methods for creating compiled Plutus V2 scripts.

Factory methods for creating compiled Plutus V2 scripts.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
PlutusV2.type

Plutus V2 cost model parameters.

Plutus V2 cost model parameters.

The names of the fields are taken from https://github.com/input-output-hk/plutus/blob/1.40.0.0/plutus-ledger-api/src/PlutusLedgerApi/V2/ParamName.hs and Blockfrost Protocol Parameters JSON uses these names as well in blockfrost-params-epoch-544.json

But what's really important is the order of the fields because that's the order of the parameters in the protocol parameters array.

Attributes

Companion
object
Supertypes
trait PlutusParams
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final case class PlutusV3[A] extends CompiledPlutus[A]

A compiled Plutus V3 script.

A compiled Plutus V3 script.

This is the primary type for working with compiled Cardano smart contracts in Scalus. It holds the intermediate representation (SIR), compilation options, and lazily computes the final UPLC program and script.

Plutus V3 was introduced in the Conway hard fork. It adds BLS12-381 elliptic curve operations, bitwise primitives, and more efficient case/constr optimization.

Type parameters

A

the Scala type of the compiled code

Value parameters

lazyCode

a thunk that evaluates to the original Scala code

optimizer

the UPLC optimizer to apply (if optimization is enabled)

options

compiler options controlling lowering and optimization

sir

the Scalus Intermediate Representation

Attributes

Example
 given scalus.compiler.Options = scalus.compiler.Options.release
 val validator = PlutusV3.compile((datum: Data) => ...)
 val scriptHash = validator.script.scriptHash
 val address = validator.address(Network.Testnet)
Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class CompiledPlutus[A]
trait Compiled[A]
class Object
trait Matchable
class Any
Show all
object PlutusV3

Factory methods for creating compiled Plutus V3 scripts.

Factory methods for creating compiled Plutus V3 scripts.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
PlutusV3.type

Plutus V3 cost model parameters.

Plutus V3 cost model parameters.

The names of the fields are taken from https://github.com/input-output-hk/plutus/blob/1.40.0.0/plutus-ledger-api/src/PlutusLedgerApi/V3/ParamName.hs and Blockfrost Protocol Parameters JSON uses these names as well in blockfrost-params-epoch-544.json

But what's really important is the order of the fields because that's the order of the parameters in the protocol parameters array.

Attributes

Companion
object
Supertypes
trait PlutusParams
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Program(version: (Int, Int, Int), term: Term)

A Cardano Plutus program.

A Cardano Plutus program.

A program is a versioned Term. The version is a tuple of three integers: major, minor, and patch.

Value parameters

term

the term of the program

version

the version of the program

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Program

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Program.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
enum Term

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Var
class LamAbs
class Apply
class Force
class Delay
class Const
class Builtin
Show all
object Term

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Term.type
object TermDSL

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
TermDSL.type
object TermSanitizer

Sanitizes UPLC Terms to ensure all variable names conform to the UPLC text format requirements.

Sanitizes UPLC Terms to ensure all variable names conform to the UPLC text format requirements.

UPLC text format only allows:

  • First character: letters (a-z, A-Z) or underscore (_)
  • Subsequent characters: letters, digits, underscore (_), or apostrophe (')
  • Optional suffix: hyphen followed by digits (-\d+)

This sanitizer transforms variable names to comply with these rules while avoiding conflicts.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
enum TypeScheme

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object UplcCli

Cardano uplc CLI interface

Cardano uplc CLI interface

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
UplcCli.type

Represents the result of evaluating a UPLC program using uplc CLI

Represents the result of evaluating a UPLC program using uplc CLI

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
class UplcParser(initialVersion: (Int, Int, Int) = ...)

UPLC parsers.

UPLC parsers.

It's a collection of parsers for the UPLC language. Term and Program parsers are statefull and are program version dependent, that's why this is a class and not an object.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object UplcParser

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
UplcParser.type

Givens