scalus.uplc.builtin

Members list

Type members

Classlikes

CIP-122 + shifts & rotations from CIP-123

CIP-122 + shifts & rotations from CIP-123

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
class BuiltinArray[A]

A builtin array type corresponding to the Plutus Core builtin array (CIP-0156).

A builtin array type corresponding to the Plutus Core builtin array (CIP-0156).

Arrays provide O(1) indexed access to elements, complementing linked lists which have O(n) access time. This makes arrays ideal for random access patterns.

Arrays are created from lists using listToArray and provide efficient indexed access via indexArray and multiIndexArray.

==UPLC Builtin Operations==

The following UPLC builtins operate on arrays (available in Plutus V4+):

  • listToArray - Convert a list to an array
  • lengthOfArray - Get the number of elements
  • indexArray - Access element at index (O(1))
  • multiIndexArray - Access multiple elements by indices

Type parameters

A

the element type

Attributes

See also
Since

Plutus V4

Companion
object
Supertypes
class Object
trait Matchable
class Any
object BuiltinArray

Companion object for BuiltinArray providing factory methods.

Companion object for BuiltinArray providing factory methods.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
enum BuiltinList[+A]

A builtin list type corresponding to the Plutus Core builtin list.

A builtin list type corresponding to the Plutus Core builtin list.

This is the Scalus equivalent of BuiltinList in Plutus. It represents an immutable singly-linked list that can be used in Plutus smart contracts.

The list supports basic operations: checking emptiness, accessing head/tail, and prepending elements. These operations correspond directly to Plutus Core builtin functions.

==UPLC Builtin Operations==

The following UPLC builtins operate on lists:

  • mkCons - Prepend element (corresponds to ::)
  • headList - Get first element (corresponds to head)
  • tailList - Get all but first (corresponds to tail)
  • nullList - Check if empty (corresponds to isEmpty)
  • chooseList - Pattern match on empty vs non-empty
  • dropList - Drop first n elements (Plutus V4+)
  • mkNilData - Create empty list of Data
  • mkNilPairData - Create empty list of Data pairs

Type parameters

A

the element type

Attributes

See also

scalus.cardano.onchain.plutus.prelude.List for higher-level list operations

Since

Plutus V1

Note

For higher-level list operations like map, filter, fold, etc., use scalus.cardano.onchain.plutus.prelude.List which provides a rich set of combinators.

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

Companion object for BuiltinList providing factory methods.

Companion object for BuiltinList providing factory methods.

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class BuiltinPair[A, B](fst: A, snd: B)

A builtin pair type corresponding to the Plutus Core builtin pair.

A builtin pair type corresponding to the Plutus Core builtin pair.

Pairs are polymorphic 2-tuples used throughout Plutus for composite data.

==UPLC Builtin Operations==

The following UPLC builtins operate on pairs:

  • fstPair - Extract the first element (corresponds to fst)
  • sndPair - Extract the second element (corresponds to snd)
  • mkPairData - Create a pair of Data values

Type parameters

A

type of the first element

B

type of the second element

Value parameters

fst

the first element

snd

the second element

Attributes

Since

Plutus V1

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

MaryEraValue (CIP-0153) - multi-asset value representation for Cardano.

MaryEraValue (CIP-0153) - multi-asset value representation for Cardano.

This is a primitive opaque type in UPLC. The inner representation is hidden - use builtin operations to work with values:

  • insertCoin to insert/update token amounts
  • lookupCoin to lookup token amounts
  • unionValue to merge two values
  • valueContains to check if one value contains another
  • scaleValue to multiply all amounts by a scalar
  • valueData / unValueData for Data conversion

Invariants maintained by operations:

  • No empty inner maps (currency symbols with no tokens are removed)
  • No zero quantities (zero-amount tokens are removed)
  • Keys max 32 bytes (currency symbols and token names)
  • Quantities in signed 128-bit range

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object BuiltinValue

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object Builtins extends Builtins

Attributes

Companion
class
Supertypes
class Builtins
class Object
trait Matchable
class Any
Self type
Builtins.type
class Builtins(using ps: PlatformSpecific)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Builtins
class ByteString extends Serializable

An immutable sequence of bytes.

An immutable sequence of bytes.

This class is used as a UPLC builtin type to represent binary data and it can be used in both onchain and offchain code.

Attributes

Note

methods of this class are only available offchain with the exception of == and !=. For onchain operations use the extension methods in the companion object

Companion
object
Supertypes
trait Serializable
class Object
trait Matchable
class Any
object ByteString

Attributes

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

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class Data

The universal data type for Plutus smart contracts.

The universal data type for Plutus smart contracts.

Data is the core serializable type used throughout Cardano for representing:

  • Script datums attached to UTxOs
  • Redeemers passed to validators
  • Arbitrary structured data in smart contracts

It corresponds to the BuiltinData type in Plutus Core and can represent any algebraic data type through its five constructors:

  • Data.Constr - Constructor application with tag and arguments (for sum/product types)
  • Data.Map - Key-value mappings
  • Data.List - Ordered sequences
  • Data.I - Arbitrary-precision integers
  • Data.B - Byte strings

==Encoding Convention==

Scalus uses the standard Plutus Data encoding:

  • Sum types use Constr with constructor index as tag
  • Product types (case classes) use Constr with fields as arguments
  • Option[A] encodes as Constr(0, []) for None, Constr(1, [value]) for Some
  • Boolean encodes as Constr(0, []) for false, Constr(1, []) for true

==UPLC Builtin Operations==

The following UPLC builtins operate on Data:

  • chooseData - Pattern match on Data constructor
  • constrData, mapData, listData, iData, bData - Construct Data values
  • unConstrData, unMapData, unListData, unIData, unBData - Deconstruct Data values
  • equalsData - Structural equality comparison
  • serialiseData - CBOR serialization (Plutus V2+)

Attributes

See also

scalus.uplc.builtin.ToData for automatic encoding to Data

scalus.uplc.builtin.FromData for automatic decoding from Data

Example
 // Encoding a simple value
 val intData: Data = Data.I(42)
 // Encoding a product type (pair)
 val pairData: Data = Data.Constr(0, List(Data.I(1), Data.I(2)))
 // Encoding a sum type (Option)
 val someData: Data = Data.Constr(1, List(Data.I(42)))  // Some(42)
 val noneData: Data = Data.Constr(0, List.Nil)          // None
Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class B
class Constr
class I
class List
class Map
object Data

Companion object for Data providing constructors and type class instances.

Companion object for Data providing constructors and type class instances.

Use the ToData and FromData type classes for automatic conversion between Scala types and Data.

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Data.type
@FunctionalInterface
trait FromData[+A] extends Data => A, CompileDerivations

Attributes

Companion
object
Supertypes
trait Data => A
class Object
trait Matchable
class Any
object FromData

FromData[A] derivation

FromData[A] derivation

Attributes

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

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

This is the platform specific part of the builtins. This is mostly cryptographic primitives that have different implementations on different platforms.

This is the platform specific part of the builtins. This is mostly cryptographic primitives that have different implementations on different platforms.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
@FunctionalInterface
trait ToData[-A] extends A => Data, CompileDerivations

Attributes

Companion
object
Supertypes
trait A => Data
class Object
trait Matchable
class Any
object ToData

ToData[A] derivation macros.

ToData[A] derivation macros.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
ToData.type
final class uplcIntrinsic(value: String) extends StaticAnnotation

Attributes

Supertypes
trait StaticAnnotation
class Annotation
class Object
trait Matchable
class Any

Deprecated types

Attributes

Deprecated
[Since version 0.15.0] Use scalus.uplc.builtin.bls12_381.G1Element instead

Use scalus.uplc.builtin.bls12_381.G1Element instead

Attributes

Deprecated
[Since version 0.15.0] Use scalus.uplc.builtin.bls12_381.G2Element instead

Use scalus.uplc.builtin.bls12_381.G2Element instead

Attributes

Deprecated
[Since version 0.15.0] Use scalus.uplc.builtin.bls12_381.MLResult instead

Use scalus.uplc.builtin.bls12_381.MLResult instead

Value members

Concrete methods

Provides access to platform-specific built-in functions.

Provides access to platform-specific built-in functions.

This is used to access cryptographic primitives and other platform-specific functionality that may vary between JVM, JS, and other platforms.

Attributes

Deprecated fields

Attributes

Deprecated
[Since version 0.15.0] Use scalus.uplc.builtin.bls12_381.G1Element instead

Use scalus.uplc.builtin.bls12_381.G1Element instead

Attributes

Deprecated
[Since version 0.15.0] Use scalus.uplc.builtin.bls12_381.G2Element instead

Use scalus.uplc.builtin.bls12_381.G2Element instead

Attributes

Deprecated
[Since version 0.15.0] Use scalus.uplc.builtin.bls12_381.MLResult instead

Use scalus.uplc.builtin.bls12_381.MLResult instead