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
Members list
Type members
Classlikes
Byte string - represents binary data.
Byte string - represents binary data.
Used to encode ByteString, PubKeyHash, CurrencySymbol, TokenName, etc.
Corresponds to UPLC builtins bData and unBData.
Value parameters
- value
-
the byte string
Attributes
- Example
-
B(ByteString.fromHex("deadbeef")) B(ByteString.empty) - Supertypes
-
trait Serializabletrait Producttrait Equalsclass Dataclass Objecttrait Matchableclass AnyShow all
Constructor application - represents sum types and product types.
Constructor application - represents sum types and product types.
This is the primary way to encode algebraic data types in Plutus:
- For sum types,
constris the constructor index (0, 1, 2, ...) - For product types (case classes),
constris typically 0 argscontains the constructor's field values
Corresponds to UPLC builtins constrData and unConstrData.
Value parameters
- args
-
the constructor arguments as a list of Data values
- constr
-
the constructor index (must be non-negative)
Attributes
- Example
-
// A pair (Int, String) Constr(0, List(I(42), B(ByteString.fromString("hello")))) // Either.Left(10) Constr(0, List(I(10))) // Either.Right("x") Constr(1, List(B(ByteString.fromString("x")))) - Supertypes
-
trait Serializabletrait Producttrait Equalsclass Dataclass Objecttrait Matchableclass AnyShow all
Arbitrary-precision integer.
Arbitrary-precision integer.
Corresponds to UPLC builtins iData and unIData.
Value parameters
- value
-
the integer value
Attributes
- Example
-
I(42) I(-1000000000000000000L) - Supertypes
-
trait Serializabletrait Producttrait Equalsclass Dataclass Objecttrait Matchableclass AnyShow all
Ordered sequence - represents list types.
Ordered sequence - represents list types.
Used to encode List[A] types where elements are Data.
Corresponds to UPLC builtins listData and unListData.
Value parameters
- values
-
the list elements
Attributes
- Example
-
// A list of integers [1, 2, 3] List(PList(I(1), I(2), I(3))) - Supertypes
-
trait Serializabletrait Producttrait Equalsclass Dataclass Objecttrait Matchableclass AnyShow all
Key-value mapping - represents associative data structures.
Key-value mapping - represents associative data structures.
Used to encode Map[K, V] types where both keys and values are Data. Note that duplicate keys are allowed (this is a list of pairs, not a true map).
Corresponds to UPLC builtins mapData and unMapData.
Value parameters
- values
-
list of key-value pairs
Attributes
- Example
-
// A map from integers to strings Map(List((I(1), B(hex"aa")), (I(2), B(hex"bb")))) - Supertypes
-
trait Serializabletrait Producttrait Equalsclass Dataclass Objecttrait Matchableclass AnyShow all
Inherited classlikes
CBOR decoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
CBOR decoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
Attributes
- Inherited from:
- DataApi (hidden)
- Supertypes
CBOR encoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
CBOR encoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
Attributes
- Inherited from:
- DataApi (hidden)
- Supertypes
Attributes
- Inherited from:
- DataApi (hidden)
- Supertypes
Pretty prints Data in debug format with rainbow brackets: <constr, [args]>, {k: v}, [v], 123, "hex"
Pretty prints Data in debug format with rainbow brackets: <constr, [args]>, {k: v}, [v], 123, "hex"
Attributes
- Inherited from:
- DataApi (hidden)
- Supertypes
Types
Type class for converting Data back to typed values.
Type class for converting Data back to typed values.
Attributes
Inherited and Abstract types
The names of the product elements
The names of the product elements
Attributes
- Inherited from:
- Mirror
The name of the type
The name of the type
Attributes
- Inherited from:
- Mirror
Value members
Concrete methods
Converts Data to type A using the FromData type class.
Converts Data to type A using the FromData type class.
Value parameters
- data
-
the Data to convert
Attributes
- Returns
-
the converted value
- Throws
-
Exception
if the Data structure doesn't match the expected type
Inherited methods
Givens
Inherited givens
CBOR decoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
CBOR decoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
Attributes
- Inherited from:
- DataApi (hidden)
CBOR encoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
CBOR encoder for the Data type. The encoding and decoding logic is based on the Cardano node implementation.
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Pretty prints Data in debug format with rainbow brackets: <constr, [args]>, {k: v}, [v], 123, "hex"
Pretty prints Data in debug format with rainbow brackets: <constr, [args]>, {k: v}, [v], 123, "hex"
Attributes
- Inherited from:
- DataApi (hidden)
Extensions
Extensions
Inherited extensions
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)
Attributes
- Inherited from:
- DataApi (hidden)