OutputDatum

scalus.cardano.onchain.plutus.v2.OutputDatum
See theOutputDatum companion enum
object OutputDatum

Attributes

Companion
enum
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete fields

lazy val sirDeps: List[SIRModuleWithDeps]
lazy val sirModule: Module

Extensions

Extensions

extension (d: OutputDatum)
inline def inlineOrFail[A : FromData]: A

Extracts the inline datum and decodes it as A.

Extracts the inline datum and decodes it as A.

Fails the script when the datum is not inline (NoOutputDatum or OutputDatumHash). This replaces the common pattern

output.datum match
   case OutputDatum.OutputDatum(d) => d.to[MyDatum]
   case _                          => fail("Expected inline datum")

with output.datum.inlineOrFail[MyDatum].

Being inline, the match is checked against the receiver's static type: calling this on a receiver the compiler already knows is NoOutputDatum or OutputDatumHash is rejected at compile time instead of failing at run time.

Type parameters

A

the datum type to decode with its FromData instance

Attributes

Example
 val datum = output.datum.inlineOrFail[CampaignDatum]
inline def inlineOrFail[A : FromData](inline message: String): A

Extracts the inline datum and decodes it as A, failing with message when the datum is not inline.

Extracts the inline datum and decodes it as A, failing with message when the datum is not inline.

Type parameters

A

the datum type to decode with its FromData instance

Attributes

Example
 val datum = output.datum.inlineOrFail[CampaignDatum]("Campaign must have inline datum")