TxInfo

scalus.cardano.onchain.plutus.v3.TxInfo
See theTxInfo companion class
object TxInfo

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TxInfo.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

Deprecated extensions

extension (self: TxInfo)
inline def findContinuingOutputOrFail(ownInput: TxInInfo, inline message: String): TxOut

Finds the unique output paying back to ownInput's address, or fails with message.

Finds the unique output paying back to ownInput's address, or fails with message.

Compares the WHOLE address, staking credential included. The credential-only finders (findOutputsByScriptHash, findOutputsByCredential) leave the staking part unconstrained, which lets an attacker redirect the continuing output's delegation rewards. Fails when no output or more than one output pays to that address.

Attributes

Example
 val ownInput = tx.findInputOrFail(ownRef)
 val continuing = tx.findContinuingOutputOrFail(ownInput, "expected one continuing output")
 require(continuing.value.hasSameTokensAndAtLeastAda(ownInput.resolved.value), "value")
def findDatum(datumHash: DatumHash): Option[Datum]

Finds a datum by its hash in this transaction's outputs or datum witness map.

Finds a datum by its hash in this transaction's outputs or datum witness map.

Attributes

Finds a transaction input by its output reference.

Finds a transaction input by its output reference.

Attributes

Returns

Some(TxInInfo) if an input spends outRef, None otherwise

inline def findInputOrFail(outRef: TxOutRef, inline message: String = ...): TxInInfo

Finds a transaction input by its output reference, or fails with message.

Finds a transaction input by its output reference, or fails with message.

A direct scan with no intermediate Option. As a statement it is also the one-shot check: tx.findInputOrFail(seed, "seed must be spent").

Attributes

Example
 val ownInput = tx.findInputOrFail(ownRef, "own input not found")

Finds all inputs whose resolved address has the given payment credential.

Finds all inputs whose resolved address has the given payment credential.

Matches the payment credential only; the staking part is not constrained.

Attributes

Finds all outputs whose address has the given payment credential.

Finds all outputs whose address has the given payment credential.

Matches the PAYMENT credential only: the staking part of the address is not constrained. Do not use this to locate the continuing output of a script - an attacker can keep the payment credential and redirect the delegation rewards. Use findContinuingOutputOrFail, which compares the whole address.

Attributes

Finds all outputs whose payment credential is the given script hash.

Finds all outputs whose payment credential is the given script hash.

Matches the PAYMENT credential only: the staking part of the address is not constrained. Do not use this to locate the continuing output of a script - an attacker can keep the payment credential and redirect the delegation rewards. Use findContinuingOutputOrFail, which compares the whole address.

Attributes

def findOwnDatum(datumHash: DatumHash): Option[Datum]

Deprecated spelling of findDatum; original body kept.

Deprecated spelling of findDatum; original body kept.

Attributes

Deprecated
[Since version 1.1.1] use findDatum

Deprecated spelling of findInput. Keeps its original body so existing budgets do not move until callers migrate.

Deprecated spelling of findInput. Keeps its original body so existing budgets do not move until callers migrate.

Attributes

Deprecated
[Since version 1.1.1] use findInput
inline def findOwnInputOrFail(outRef: TxOutRef, inline message: String = ...): TxInInfo

Deprecated spelling of findInputOrFail. Keeps its original Option-based body so the budgets of existing callers do not move until they migrate.

Deprecated spelling of findInputOrFail. Keeps its original Option-based body so the budgets of existing callers do not move until they migrate.

Attributes

Deprecated
[Since version 1.1.1] use findInputOrFail
def findOwnInputs(pred: TxInInfo => Boolean): List[TxInInfo]

Same as inputs.filter(pred).

Same as inputs.filter(pred).

Attributes

Deprecated
[Since version 1.1.1] use inputs.filter

Deprecated spelling of findInputsByCredential; original body kept.

Deprecated spelling of findInputsByCredential; original body kept.

Attributes

Deprecated
[Since version 1.1.1] use findInputsByCredential
def findOwnOutputs(pred: TxOut => Boolean): List[TxOut]

Same as outputs.filter(pred).

Same as outputs.filter(pred).

Attributes

Deprecated
[Since version 1.1.1] use outputs.filter

Deprecated spelling of findOutputsByCredential; original body kept.

Deprecated spelling of findOutputsByCredential; original body kept.

Attributes

Deprecated
[Since version 1.1.1] use findOutputsByCredential

Deprecated spelling of findOutputsByScriptHash; original body kept.

Deprecated spelling of findOutputsByScriptHash; original body kept.

Attributes

Deprecated
[Since version 1.1.1] use findOutputsByScriptHash
def getValidityStartTime: BigInt

Extracts the start time from the transaction's validity interval, or 0 if the range has no finite lower bound.

Extracts the start time from the transaction's validity interval, or 0 if the range has no finite lower bound.

A transaction with NO lower bound is then treated as happening at the Unix epoch, and every "has the deadline passed?" comparison flips. Use validFromOrFail.

Attributes

Deprecated
[Since version 1.1.1] use validFromOrFail
def hasPaidTagged(addr: Address, value: Value, tag: OutputDatum): Boolean

true if some output pays EXACTLY value to addr and carries tag as its datum.

true if some output pays EXACTLY value to addr and carries tag as its datum.

The tagged-output defence against double satisfaction: with a TxOutRef-derived tag (see TxOutRef.deriveTokenName) no single output can satisfy two script instances. All three comparisons are exact; a >= on the value would reopen the hole.

Attributes

def isSignedBy(pubKeyHash: PubKeyHash): Boolean

Attributes

Returns

true if the transaction signatories list includes the given keyHash, false otherwise

def isSignedByAny(keys: List[PubKeyHash]): Boolean

true if any of keys signed the transaction.

true if any of keys signed the transaction.

A direct scan; keys.exists(tx.isSignedBy) allocates an Option per call.

Attributes

def onlyBurnsUnder(policy: PolicyId): Boolean

true if at least one token is minted or burned under policy and every quantity under it is negative.

true if at least one token is minted or burned under policy and every quantity under it is negative.

Not mint.tokens(policy).forall(_._2 &lt; 0): forall over an EMPTY map is vacuously true, so that spelling passes a transaction that burns nothing at all. An auction that closes by burning its state NFT with the unguarded check lets a Close that mints nothing pay out while the NFT survives for replay. The emptiness guard is the operation. When the token name is known, mint.hasOnly(policy, name, -1) is stronger.

Attributes

inline def validFromOrFail(inline message: String): PosixTime

The validity range's lower bound, or fails with message if it is unbounded.

The validity range's lower bound, or fails with message if it is unbounded.

INCLUSIVE: the ledger builds it with lowerBound (closed), so this is the earliest time at which the transaction can be included. It is the value to compare against a "not before" deadline: require(tx.validFromOrFail(msg) >= deadline, "too early").

Pairs with TxBuilder.validFrom. Replaces getValidityStartTime, which returned 0 for an unbounded range and let a transaction with no lower bound pass every deadline.

Attributes

inline def validToOrFail(inline message: String): PosixTime

The validity range's upper bound, or fails with message if it is unbounded.

The validity range's upper bound, or fails with message if it is unbounded.

EXCLUSIVE: the ledger builds it with strictUpperBound (open), so the transaction cannot be included at or after this time. A timestamp written into a datum from this value is an upper bound on the real posting time - it can be late, never early. It is the value to compare against a "not after" deadline: require(tx.validToOrFail(msg) &lt;= deadline, "too late").

Pairs with TxBuilder.validTo.

Attributes

def valuePaidTo(addr: Address): Value

Total value paid to addr across all outputs, as a whole Value.

Total value paid to addr across all outputs, as a whole Value.

Compares the whole address. Sums every asset, not only lovelace; project with .getLovelace afterwards when only ADA matters.

Attributes

Total value spent from addr across all inputs, as a whole Value.

Total value spent from addr across all inputs, as a whole Value.

Compares the whole address. Sums every asset, not only lovelace.

Attributes