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 Objecttrait Matchableclass Any
- Self type
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 arraylengthOfArray- Get the number of elementsindexArray- 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 Objecttrait Matchableclass Any
Companion object for BuiltinArray providing factory methods.
Companion object for BuiltinArray providing factory methods.
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
BuiltinArray.type
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 tohead)tailList- Get all but first (corresponds totail)nullList- Check if empty (corresponds toisEmpty)chooseList- Pattern match on empty vs non-emptydropList- Drop first n elements (Plutus V4+)mkNilData- Create empty list of DatamkNilPairData- 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 Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Companion object for BuiltinList providing factory methods.
Companion object for BuiltinList providing factory methods.
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
BuiltinList.type
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 tofst)sndPair- Extract the second element (corresponds tosnd)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 Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
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:
insertCointo insert/update token amountslookupCointo lookup token amountsunionValueto merge two valuesvalueContainsto check if one value contains anotherscaleValueto multiply all amounts by a scalarvalueData/unValueDatafor 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 Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
BuiltinValue.type
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 Serializableclass Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ByteString.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ByteStringToInteger.type
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
Constrwith constructor index as tag - Product types (case classes) use
Constrwith fields as arguments Option[A]encodes asConstr(0, [])forNone,Constr(1, [value])forSomeBooleanencodes asConstr(0, [])forfalse,Constr(1, [])fortrue
==UPLC Builtin Operations==
The following UPLC builtins operate on Data:
chooseData- Pattern match on Data constructorconstrData,mapData,listData,iData,bData- Construct Data valuesunConstrData,unMapData,unListData,unIData,unBData- Deconstruct Data valuesequalsData- Structural equality comparisonserialiseData- 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 Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Companion
- object
- Supertypes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
IntegerToByteString.type
Attributes
- Companion
- trait
- Supertypes
- Self type
-
JVMPlatformSpecific.type
Attributes
- Companion
- object
- Supertypes
- Known subtypes
-
object JVMPlatformSpecific
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 Objecttrait Matchableclass Any
- Known subtypes
-
trait JVMPlatformSpecificobject JVMPlatformSpecific
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PlatformSpecific.type
Attributes
- Companion
- object
- Supertypes
Attributes
- Supertypes
-
trait StaticAnnotationclass Annotationclass Objecttrait Matchableclass Any
Deprecated types
Attributes
- Deprecated
-
[Since version 0.15.0]Use scalus.uplc.builtin.bls12_381.G1Element insteadUse scalus.uplc.builtin.bls12_381.G1Element instead
Attributes
- Deprecated
-
[Since version 0.15.0]Use scalus.uplc.builtin.bls12_381.G2Element insteadUse scalus.uplc.builtin.bls12_381.G2Element instead
Attributes
- Deprecated
-
[Since version 0.15.0]Use scalus.uplc.builtin.bls12_381.MLResult insteadUse 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 insteadUse scalus.uplc.builtin.bls12_381.G1Element instead
Attributes
- Deprecated
-
[Since version 0.15.0]Use scalus.uplc.builtin.bls12_381.G2Element insteadUse scalus.uplc.builtin.bls12_381.G2Element instead
Attributes
- Deprecated
-
[Since version 0.15.0]Use scalus.uplc.builtin.bls12_381.MLResult insteadUse scalus.uplc.builtin.bls12_381.MLResult instead