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
Datatype - '''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
-
scalus.uplc.builtin.Builtins for the Scala implementations
- Companion
- object
- Graph
-
- Supertypes
-
trait Enumtrait Producttrait Equalsclass Enum[DefaultFun]trait Serializabletrait Comparable[DefaultFun]trait Constableclass Objecttrait Matchableclass AnyShow all
Members list
Type members
Enum entries
Add two integers.
Add two integers.
'''Type:''' Integer -> Integer -> Integer
Attributes
- Since
-
Plutus V1
- Example
-
addInteger(3, 5)returns8
Bitwise AND of two bytestrings.
Bitwise AND of two bytestrings.
'''Type:''' Bool -> ByteString -> ByteString -> ByteString
The Bool controls padding behavior for different-length inputs:
false: result has length of shorter input (truncating)true: result has length of longer input (padding with remaining bytes)
Attributes
- Since
-
Plutus V3 (CIP-122)
- Example
-
andByteString(false, hex"0FFF", hex"FF")returnshex"0F"andByteString(true, hex"0FFF", hex"FF")returnshex"0FFF"
Concatenate two bytestrings.
Concatenate two bytestrings.
'''Type:''' ByteString -> ByteString -> ByteString
Attributes
- Since
-
Plutus V1
- Example
-
appendByteString(hex"1234", hex"5678")returnshex"12345678"
Concatenate two strings.
Concatenate two strings.
'''Type:''' String -> String -> String
Attributes
- Since
-
Plutus V1
- Example
-
appendString("Hello, ", "World!")returns"Hello, World!"
Construct a Data value representing a bytestring.
Construct a Data value representing a bytestring.
'''Type:''' ByteString -> Data
Attributes
- Since
-
Plutus V1
- Example
-
bData(hex"1234")createsB #1234
Compute BLAKE2b-224 hash.
Compute BLAKE2b-224 hash.
'''Type:''' ByteString -> ByteString
Produces a 28-byte (224-bit) hash digest.
Attributes
- Since
-
Plutus V3
Compute BLAKE2b-256 hash.
Compute BLAKE2b-256 hash.
'''Type:''' ByteString -> ByteString
Produces a 32-byte (256-bit) hash digest. This is the primary hash function used in Cardano for script hashing and transaction IDs.
Attributes
- Since
-
Plutus V1
Add two G1 curve points.
Add two G1 curve points.
'''Type:''' G1_Element -> G1_Element -> G1_Element
Attributes
- Since
-
Plutus V3 (CIP-381)
Compress a G1 point to 48 bytes.
Compress a G1 point to 48 bytes.
'''Type:''' G1_Element -> ByteString
Attributes
- Since
-
Plutus V3 (CIP-381)
Check equality of two G1 points.
Check equality of two G1 points.
'''Type:''' G1_Element -> G1_Element -> Bool
Attributes
- Since
-
Plutus V3 (CIP-381)
Hash arbitrary data to a G1 curve point.
Hash arbitrary data to a G1 curve point.
'''Type:''' ByteString -> ByteString -> G1_Element
Uses hash-to-curve with a domain separation tag (DST). First argument is the message, second is the DST.
Attributes
- Since
-
Plutus V3 (CIP-381)
Multi-scalar multiplication on G1.
Multi-scalar multiplication on G1.
'''Type:''' [Integer] -> [G1_Element] -> G1_Element
Computes the sum ∑(i=0 to N-1) scalar_i × point_i efficiently using Pippenger's algorithm. Both input lists must be non-empty and have equal length.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if either list is empty or lists have different lengths
- Since
-
Plutus V4 (CIP-133)
Negate a G1 curve point.
Negate a G1 curve point.
'''Type:''' G1_Element -> G1_Element
Attributes
- Since
-
Plutus V3 (CIP-381)
Scalar multiplication on G1.
Scalar multiplication on G1.
'''Type:''' Integer -> G1_Element -> G1_Element
Multiplies the point by a scalar integer.
Attributes
- Since
-
Plutus V3 (CIP-381)
Decompress a 48-byte representation to a G1 point.
Decompress a 48-byte representation to a G1 point.
'''Type:''' ByteString -> G1_Element
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the bytes don't represent a valid G1 point
- Since
-
Plutus V3 (CIP-381)
Add two G2 curve points.
Add two G2 curve points.
'''Type:''' G2_Element -> G2_Element -> G2_Element
Attributes
- Since
-
Plutus V3 (CIP-381)
Compress a G2 point to 96 bytes.
Compress a G2 point to 96 bytes.
'''Type:''' G2_Element -> ByteString
Attributes
- Since
-
Plutus V3 (CIP-381)
Check equality of two G2 points.
Check equality of two G2 points.
'''Type:''' G2_Element -> G2_Element -> Bool
Attributes
- Since
-
Plutus V3 (CIP-381)
Hash arbitrary data to a G2 curve point.
Hash arbitrary data to a G2 curve point.
'''Type:''' ByteString -> ByteString -> G2_Element
Attributes
- Since
-
Plutus V3 (CIP-381)
Multi-scalar multiplication on G2.
Multi-scalar multiplication on G2.
'''Type:''' [Integer] -> [G2_Element] -> G2_Element
Computes the sum ∑(i=0 to N-1) scalar_i × point_i efficiently using Pippenger's algorithm. Both input lists must be non-empty and have equal length.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if either list is empty or lists have different lengths
- Since
-
Plutus V4 (CIP-133)
Negate a G2 curve point.
Negate a G2 curve point.
'''Type:''' G2_Element -> G2_Element
Attributes
- Since
-
Plutus V3 (CIP-381)
Scalar multiplication on G2.
Scalar multiplication on G2.
'''Type:''' Integer -> G2_Element -> G2_Element
Attributes
- Since
-
Plutus V3 (CIP-381)
Decompress a 96-byte representation to a G2 point.
Decompress a 96-byte representation to a G2 point.
'''Type:''' ByteString -> G2_Element
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the bytes don't represent a valid G2 point
- Since
-
Plutus V3 (CIP-381)
Perform final pairing verification.
Perform final pairing verification.
'''Type:''' MlResult -> MlResult -> Bool
Returns true if the final exponentiation of both results are equal, i.e., checks that e(P1, Q1) * ... = e(P2, Q2) * ....
Attributes
- Since
-
Plutus V3 (CIP-381)
Compute the Miller loop for pairing.
Compute the Miller loop for pairing.
'''Type:''' G1_Element -> G2_Element -> MlResult
Computes the intermediate pairing result, which can be combined with mulMlResult and verified with finalVerify.
Attributes
- Since
-
Plutus V3 (CIP-381)
Multiply two Miller loop results.
Multiply two Miller loop results.
'''Type:''' MlResult -> MlResult -> MlResult
Used to combine multiple pairing computations before final verification.
Attributes
- Since
-
Plutus V3 (CIP-381)
Convert a bytestring to an unsigned integer.
Convert a bytestring to an unsigned integer.
'''Type:''' Bool -> ByteString -> Integer
Parameters:
- Bool:
truefor big-endian,falsefor little-endian - ByteString: the bytes to interpret as an unsigned integer
Attributes
- Since
-
Plutus V3 (CIP-121)
- Example
-
byteStringToInteger(true, hex"1234")returns4660
Pattern match on the Data type.
Pattern match on the Data type.
'''Type:''' ∀a. Data -> a -> a -> a -> a -> a -> a
Requires one force application. Arguments after Data are: constr case, map case, list case, integer case, bytestring case. Returns the argument corresponding to the Data constructor.
Attributes
- Since
-
Plutus V1
Pattern match on a list (empty vs non-empty).
Pattern match on a list (empty vs non-empty).
'''Type:''' ∀a b. List a -> b -> b -> b
Requires two force applications. Returns the second argument if the list is empty, third argument otherwise.
Attributes
- Since
-
Plutus V1
Choose based on unit value.
Choose based on unit value.
'''Type:''' ∀a. Unit -> a -> a
Requires one force to instantiate the type variable. Always returns the second argument after evaluating the first (which must be unit).
Attributes
- Since
-
Plutus V1
Bitwise complement (NOT) of a bytestring.
Bitwise complement (NOT) of a bytestring.
'''Type:''' ByteString -> ByteString
Inverts all bits in the bytestring.
Attributes
- Since
-
Plutus V3 (CIP-122)
- Example
-
complementByteString(hex"F0")returnshex"0F"
Prepend a byte to a bytestring.
Prepend a byte to a bytestring.
'''Type:''' Integer -> ByteString -> ByteString
The integer must be in the range [0, 255].
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if byte value is outside [0, 255]
- Since
-
Plutus V1
- Example
-
consByteString(0x12, hex"3456")returnshex"123456"
Construct a Data value representing a constructor application.
Construct a Data value representing a constructor application.
'''Type:''' Integer -> List Data -> Data
Attributes
- Since
-
Plutus V1
- Example
-
constrData(0, [iData(42)])createsConstr 0 [I 42]
Count the number of set bits (population count).
Count the number of set bits (population count).
'''Type:''' ByteString -> Integer
Attributes
- Since
-
Plutus V3 (CIP-123)
- Example
-
countSetBits(hex"000F")returns4
Decode UTF-8 bytes to a string.
Decode UTF-8 bytes to a string.
'''Type:''' ByteString -> String
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the bytestring is not valid UTF-8
- Since
-
Plutus V1
Divide two integers using floor division (truncate toward negative infinity).
Divide two integers using floor division (truncate toward negative infinity).
'''Type:''' Integer -> Integer -> Integer
For negative dividends with positive divisors (or vice versa), this differs from truncated division (quotientInteger) by rounding toward negative infinity.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if divisor is zero
- Since
-
Plutus V1
- Example
-
divideInteger(7, 2)returns3divideInteger(-7, 2)returns-4(floor division)
Drop the first n elements from a list.
Drop the first n elements from a list.
'''Type:''' ∀a. Integer -> List a -> List a
Requires one force application. If n is negative, returns the original list. If n exceeds the list length, returns an empty list.
Attributes
- See also
- Since
-
Plutus V4
- Example
-
dropList(2, [1, 2, 3, 4])returns[3, 4]
Encode a string as UTF-8 bytes.
Encode a string as UTF-8 bytes.
'''Type:''' String -> ByteString
Attributes
- Since
-
Plutus V1
- Example
-
encodeUtf8("hello")returnshex"68656c6c6f"
Check if two bytestrings are equal.
Check if two bytestrings are equal.
'''Type:''' ByteString -> ByteString -> Bool
Attributes
- Since
-
Plutus V1
- Example
-
equalsByteString(hex"1234", hex"1234")returnstrue
Check if two Data values are equal.
Check if two Data values are equal.
'''Type:''' Data -> Data -> Bool
Performs deep structural equality comparison.
Attributes
- Since
-
Plutus V1
Check if two integers are equal.
Check if two integers are equal.
'''Type:''' Integer -> Integer -> Bool
Attributes
- Since
-
Plutus V1
- Example
-
equalsInteger(5, 5)returnstrue
Check if two strings are equal.
Check if two strings are equal.
'''Type:''' String -> String -> Bool
Attributes
- Since
-
Plutus V1
Compute modular exponentiation.
Compute modular exponentiation.
'''Type:''' Integer -> Integer -> Integer -> Integer
Computes base^exponent mod modulus. Supports negative exponents via modular inverse.
Parameters:
- base: the base integer
- exponent: the exponent (can be negative if base is invertible mod modulus)
- modulus: the modulus (must be positive)
Semantics:
- If modulus <= 0: error
- If modulus == 1: returns 0
- If exponent >= 0: returns base^exponent mod modulus
- If exponent < 0 and gcd(base, modulus) == 1: returns (base^(-1))^(-exponent) mod modulus
- If exponent < 0 and gcd(base, modulus) != 1: error (base not invertible)
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if modulus <= 0 or base not invertible for negative exponent
- See also
- Since
-
Plutus V3
- Example
-
expModInteger(2, 10, 1000)returns24(2^10 mod 1000)expModInteger(3, -1, 7)returns5(modular inverse of 3 mod 7)
Find the index of the first set bit.
Find the index of the first set bit.
'''Type:''' ByteString -> Integer
Returns -1 if no bits are set. Index 0 is the least significant bit.
Attributes
- Since
-
Plutus V3 (CIP-123)
- Example
-
findFirstSetBit(hex"0002")returns1findFirstSetBit(hex"0000")returns-1
Extract the first element of a pair.
Extract the first element of a pair.
'''Type:''' ∀a b. Pair a b -> a
Requires two force applications to instantiate both type variables.
Attributes
- Since
-
Plutus V1
Get the first element of a non-empty list.
Get the first element of a non-empty list.
'''Type:''' ∀a. List a -> a
Requires one force application.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the list is empty
- Since
-
Plutus V1
Construct a Data value representing an integer.
Construct a Data value representing an integer.
'''Type:''' Integer -> Data
Attributes
- Since
-
Plutus V1
- Example
-
iData(42)createsI 42
Conditional expression (if-then-else).
Conditional expression (if-then-else).
'''Type:''' ∀a. Bool -> a -> a -> a
Requires one force to instantiate the type variable. Returns the second argument if the condition is true, third argument otherwise.
Attributes
- Since
-
Plutus V1
- Example
-
force(ifThenElse) true x yevaluates tox
Access an element by index.
Access an element by index.
'''Type:''' ∀a. Array a -> Integer -> a
Requires one force application.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if index is out of bounds
- Since
-
Plutus V4 (CIP-156)
Get the byte at a specific index in a bytestring.
Get the byte at a specific index in a bytestring.
'''Type:''' ByteString -> Integer -> Integer
Returns an unsigned byte value in [0, 255]. Index is 0-based.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if index is out of bounds
- Since
-
Plutus V1
- Example
-
indexByteString(hex"1234", 0)returns0x12
Insert or update a token amount in a Value.
Insert or update a token amount in a Value.
'''Type:''' ByteString -> ByteString -> Integer -> Value -> Value
Parameters: currency symbol (policy ID, max 32 bytes), token name (max 32 bytes), amount, and the Value to modify. Use amount 0 to remove a token.
Attributes
- Since
-
Plutus V4 (CIP-153)
Convert an integer to a bytestring.
Convert an integer to a bytestring.
'''Type:''' Bool -> Integer -> Integer -> ByteString
Parameters:
- First Bool:
truefor big-endian,falsefor little-endian - First Integer: target length in bytes (0 for minimal representation)
- Second Integer: the unsigned integer to convert (must be non-negative)
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if integer is negative or doesn't fit in specified length
- Since
-
Plutus V3 (CIP-121)
- Example
-
integerToByteString(true, 2, 4660)returnshex"1234"integerToByteString(false, 2, 4660)returnshex"3412"(little-endian)
Compute Keccak-256 hash.
Compute Keccak-256 hash.
'''Type:''' ByteString -> ByteString
Produces a 32-byte hash. This is the hash function used by Ethereum.
Attributes
- Since
-
Plutus V3
- Note
-
This is Keccak-256, not the NIST SHA3-256 standard (which differs in padding).
Get the length of an array.
Get the length of an array.
'''Type:''' ∀a. Array a -> Integer
Requires one force application.
Attributes
- Since
-
Plutus V4 (CIP-156)
Get the length of a bytestring in bytes.
Get the length of a bytestring in bytes.
'''Type:''' ByteString -> Integer
Attributes
- Since
-
Plutus V1
- Example
-
lengthOfByteString(hex"1234")returns2
Check if the first bytestring is lexicographically less than the second.
Check if the first bytestring is lexicographically less than the second.
'''Type:''' ByteString -> ByteString -> Bool
Comparison is byte-by-byte, treating bytes as unsigned. Shorter bytestrings are considered less than longer ones with the same prefix.
Attributes
- Since
-
Plutus V1
- Example
-
lessThanByteString(hex"12", hex"1234")returnstrue
Check if the first bytestring is lexicographically less than or equal to the second.
Check if the first bytestring is lexicographically less than or equal to the second.
'''Type:''' ByteString -> ByteString -> Bool
Attributes
- Since
-
Plutus V1
- Example
-
lessThanEqualsByteString(hex"1234", hex"1234")returnstrue
Check if the first integer is less than or equal to the second.
Check if the first integer is less than or equal to the second.
'''Type:''' Integer -> Integer -> Bool
Attributes
- Since
-
Plutus V1
- Example
-
lessThanEqualsInteger(5, 5)returnstrue
Check if the first integer is strictly less than the second.
Check if the first integer is strictly less than the second.
'''Type:''' Integer -> Integer -> Bool
Attributes
- Since
-
Plutus V1
- Example
-
lessThanInteger(3, 5)returnstrue
Construct a Data value representing a list.
Construct a Data value representing a list.
'''Type:''' List Data -> Data
Attributes
- Since
-
Plutus V1
Convert a list to an array.
Convert a list to an array.
'''Type:''' ∀a. List a -> Array a
Requires one force application.
Attributes
- Since
-
Plutus V4 (CIP-156)
Look up a token amount in a Value.
Look up a token amount in a Value.
'''Type:''' ByteString -> ByteString -> Value -> Integer
Returns 0 if the token is not present.
Attributes
- Since
-
Plutus V4 (CIP-153)
Construct a Data value representing a map.
Construct a Data value representing a map.
'''Type:''' List (Pair Data Data) -> Data
Attributes
- Since
-
Plutus V1
Prepend an element to a list.
Prepend an element to a list.
'''Type:''' ∀a. a -> List a -> List a
Requires one force application.
Attributes
- Since
-
Plutus V1
- Example
-
mkCons(1, mkCons(2, nil))creates list[1, 2]
Create an empty list of Data values.
Create an empty list of Data values.
'''Type:''' Unit -> List Data
Attributes
- Since
-
Plutus V1
Create an empty list of Data pairs.
Create an empty list of Data pairs.
'''Type:''' Unit -> List (Pair Data Data)
Useful for constructing empty maps.
Attributes
- Since
-
Plutus V1
Create a pair of Data values.
Create a pair of Data values.
'''Type:''' Data -> Data -> Pair Data Data
This is a monomorphized version of pair construction for Data.
Attributes
- Since
-
Plutus V1
Compute the modulus after floor division (divideInteger).
Compute the modulus after floor division (divideInteger).
'''Type:''' Integer -> Integer -> Integer
The result has the same sign as the divisor. Satisfies: dividend = divideInteger(dividend, divisor) * divisor + modInteger(dividend, divisor)
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if divisor is zero
- Since
-
Plutus V1
- Example
-
modInteger(7, 3)returns1modInteger(-7, 3)returns2(result has sign of divisor)
Access multiple elements by indices.
Access multiple elements by indices.
'''Type:''' ∀a. List Integer -> Array a -> List a
Requires one force application. Returns elements at the specified indices in order.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if any index is out of bounds
- Since
-
Plutus V4 (CIP-156)
Multiply two integers.
Multiply two integers.
'''Type:''' Integer -> Integer -> Integer
Attributes
- Since
-
Plutus V1
- Example
-
multiplyInteger(4, 5)returns20
Check if a list is empty.
Check if a list is empty.
'''Type:''' ∀a. List a -> Bool
Requires one force application.
Attributes
- Since
-
Plutus V1
Bitwise OR of two bytestrings.
Bitwise OR of two bytestrings.
'''Type:''' Bool -> ByteString -> ByteString -> ByteString
Attributes
- Since
-
Plutus V3 (CIP-122)
- Example
-
orByteString(false, hex"0FFF", hex"FF")returnshex"FF"orByteString(true, hex"0FFF", hex"FF")returnshex"FFFF"
Compute the quotient of two integers (truncate toward zero).
Compute the quotient of two integers (truncate toward zero).
'''Type:''' Integer -> Integer -> Integer
This is standard truncated division, which rounds toward zero.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if divisor is zero
- Since
-
Plutus V1
- Example
-
quotientInteger(7, 2)returns3quotientInteger(-7, 2)returns-3(truncated toward zero)
Read a single bit from a bytestring.
Read a single bit from a bytestring.
'''Type:''' ByteString -> Integer -> Bool
Bit indexing starts from the end (least significant bit of last byte is index 0).
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if index is out of bounds
- Since
-
Plutus V3 (CIP-122)
- Example
-
readBit(hex"0004", 2)returnstrue
Compute the remainder after truncated division (quotientInteger).
Compute the remainder after truncated division (quotientInteger).
'''Type:''' Integer -> Integer -> Integer
The result has the same sign as the dividend. Satisfies: dividend = quotientInteger(dividend, divisor) * divisor + remainderInteger(dividend, divisor)
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if divisor is zero
- Since
-
Plutus V1
- Example
-
remainderInteger(7, 3)returns1remainderInteger(-7, 3)returns-1
Create a bytestring by repeating a byte value.
Create a bytestring by repeating a byte value.
'''Type:''' Integer -> Integer -> ByteString
First integer is length, second is the byte value [0, 255].
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if length is negative or byte is outside [0, 255]
- Since
-
Plutus V3 (CIP-122)
- Example
-
replicateByte(4, 0xFF)returnshex"FFFFFFFF"
Compute RIPEMD-160 hash.
Compute RIPEMD-160 hash.
'''Type:''' ByteString -> ByteString
Produces a 20-byte (160-bit) hash digest. Used in Bitcoin address derivation.
Attributes
- See also
- Since
-
Plutus V3
Rotate bits in a bytestring.
Rotate bits in a bytestring.
'''Type:''' ByteString -> Integer -> ByteString
Positive rotation moves bits left; bits shifted out wrap around to the right.
Attributes
- Since
-
Plutus V3 (CIP-123)
- Example
-
rotateByteString(hex"000F", 4)returnshex"00F0"rotateByteString(hex"000F", -4)returnshex"F000"
Scale all token amounts in a Value by a multiplier.
Scale all token amounts in a Value by a multiplier.
'''Type:''' Integer -> Value -> Value
Attributes
- Since
-
Plutus V4 (CIP-153)
Serialize a Data value to CBOR bytes.
Serialize a Data value to CBOR bytes.
'''Type:''' Data -> ByteString
Produces CBOR-encoded representation of the Data value.
Attributes
- Since
-
Plutus V2
Compute SHA2-256 hash.
Compute SHA2-256 hash.
'''Type:''' ByteString -> ByteString
Produces a 32-byte (256-bit) hash digest.
Attributes
- Since
-
Plutus V1
- Example
-
sha2_256(hex"")returns the SHA2-256 hash of empty input
Compute SHA3-256 hash.
Compute SHA3-256 hash.
'''Type:''' ByteString -> ByteString
Produces a 32-byte (256-bit) hash digest using the Keccak-based SHA3.
Attributes
- Since
-
Plutus V1
Shift bits in a bytestring.
Shift bits in a bytestring.
'''Type:''' ByteString -> Integer -> ByteString
Positive shift moves bits left (toward higher indices), negative moves right. Bits shifted out are lost; new bits are zero.
Attributes
- Since
-
Plutus V3 (CIP-123)
- Example
-
shiftByteString(hex"000F", 4)returnshex"00F0"shiftByteString(hex"000F", -4)returnshex"0000"
Extract a slice from a bytestring.
Extract a slice from a bytestring.
'''Type:''' Integer -> Integer -> ByteString -> ByteString
Parameters are: start index (inclusive), length, and source bytestring. If start is beyond the end, returns empty. If length exceeds available bytes, returns as many bytes as available.
Attributes
- Since
-
Plutus V1
- Example
-
sliceByteString(2, 4, hex"1234567890abcdef")returnshex"567890ab"sliceByteString(5, 10, hex"1234567890abcdef")returnshex"abcdef"(truncated)
Extract the second element of a pair.
Extract the second element of a pair.
'''Type:''' ∀a b. Pair a b -> b
Requires two force applications to instantiate both type variables.
Attributes
- Since
-
Plutus V1
Subtract two integers.
Subtract two integers.
'''Type:''' Integer -> Integer -> Integer
Attributes
- Since
-
Plutus V1
- Example
-
subtractInteger(10, 3)returns7
Get all elements except the first from a non-empty list.
Get all elements except the first from a non-empty list.
'''Type:''' ∀a. List a -> List a
Requires one force application.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the list is empty
- Since
-
Plutus V1
Trace a message and return a value.
Trace a message and return a value.
'''Type:''' ∀a. String -> a -> a
Requires one force to instantiate the type variable. Logs the string message (for debugging) and returns the second argument unchanged.
Attributes
- Since
-
Plutus V1
- Note
-
In on-chain execution, traces are typically collected but don't affect the result.
Extract the bytestring from a ByteString Data value.
Extract the bytestring from a ByteString Data value.
'''Type:''' Data -> ByteString
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the Data is not a ByteString
- Since
-
Plutus V1
Extract constructor index and arguments from a Constr Data value.
Extract constructor index and arguments from a Constr Data value.
'''Type:''' Data -> Pair Integer (List Data)
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the Data is not a Constr
- Since
-
Plutus V1
Extract the integer from an Integer Data value.
Extract the integer from an Integer Data value.
'''Type:''' Data -> Integer
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the Data is not an Integer
- Since
-
Plutus V1
Extract the list from a List Data value.
Extract the list from a List Data value.
'''Type:''' Data -> List Data
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the Data is not a List
- Since
-
Plutus V1
Extract the map from a Map Data value.
Extract the map from a Map Data value.
'''Type:''' Data -> List (Pair Data Data)
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if the Data is not a Map
- Since
-
Plutus V1
Convert Data to a Value.
Convert Data to a Value.
'''Type:''' Data -> Value
The Data must have the structure Map ByteString (Map ByteString Integer).
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if Data doesn't have the expected structure
- Since
-
Plutus V4 (CIP-153)
Merge two Values by adding corresponding token amounts.
Merge two Values by adding corresponding token amounts.
'''Type:''' Value -> Value -> Value
Attributes
- Since
-
Plutus V4 (CIP-153)
Check if one Value contains at least the amounts in another.
Check if one Value contains at least the amounts in another.
'''Type:''' Value -> Value -> Bool
Returns true if the first Value has at least as much of every token as the second Value.
Attributes
- Since
-
Plutus V4 (CIP-153)
Convert a Value to its Data representation.
Convert a Value to its Data representation.
'''Type:''' Value -> Data
Attributes
- Since
-
Plutus V4 (CIP-153)
Verify an ECDSA signature on the secp256k1 curve.
Verify an ECDSA signature on the secp256k1 curve.
'''Type:''' ByteString -> ByteString -> ByteString -> Bool
Parameters are: public key (33 bytes compressed), message hash (32 bytes), signature (64 bytes, r||s format).
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if inputs have wrong lengths
- Since
-
Plutus V2
- Note
-
The message must be pre-hashed (typically with SHA-256 or Keccak-256).
Verify an Ed25519 signature.
Verify an Ed25519 signature.
'''Type:''' ByteString -> ByteString -> ByteString -> Bool
Parameters are: public key (32 bytes), message, signature (64 bytes).
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if key or signature has wrong length
- Since
-
Plutus V1
- Example
-
verifyEd25519Signature(pubKey, message, signature)returnstrueif valid
Verify a Schnorr signature on the secp256k1 curve (BIP-340).
Verify a Schnorr signature on the secp256k1 curve (BIP-340).
'''Type:''' ByteString -> ByteString -> ByteString -> Bool
Parameters are: public key (32 bytes x-only), message (arbitrary), signature (64 bytes).
Attributes
- Since
-
Plutus V2
Write multiple bits in a bytestring.
Write multiple bits in a bytestring.
'''Type:''' ByteString -> List Integer -> Bool -> ByteString
Sets all bits at the specified indices to the given boolean value.
Attributes
- Throws
-
scalus.uplc.eval.BuiltinException
if any index is out of bounds
- Since
-
Plutus V3 (CIP-122)
- Example
-
writeBits(hex"0000", [0, 1, 2, 3], true)returnshex"000F"
Bitwise XOR of two bytestrings.
Bitwise XOR of two bytestrings.
'''Type:''' Bool -> ByteString -> ByteString -> ByteString
Attributes
- Since
-
Plutus V3 (CIP-122)
- Example
-
xorByteString(false, hex"0FFF", hex"FF")returnshex"F0"