TxInfo

scalus.cardano.onchain.plutus.v3.TxInfo
See theTxInfo companion object
case class TxInfo(inputs: List[TxInInfo], referenceInputs: List[TxInInfo] = ..., outputs: List[TxOut] = ..., fee: Lovelace = ..., mint: Value = ..., certificates: List[TxCert] = ..., withdrawals: SortedMap[Credential, Lovelace] = ..., validRange: Interval = ..., signatories: List[PubKeyHash] = ..., redeemers: AssocMap[ScriptPurpose, Redeemer] = ..., data: SortedMap[DatumHash, Datum] = ..., id: TxId, votes: SortedMap[Voter, SortedMap[GovernanceActionId, Vote]] = ..., proposalProcedures: List[ProposalProcedure] = ..., currentTreasuryAmount: Option[Lovelace] = ..., treasuryDonation: Option[Lovelace] = ...)

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

inline def findContinuingOutputOrFail(ownInput: TxInInfo, inline message: String): TxOut
Extension method from TxInfo

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]
Extension method from TxInfo

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

Extension method from TxInfo

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
Extension method from TxInfo

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")
Extension method from TxInfo

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

Extension method from TxInfo

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

Extension method from TxInfo

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 hasPaidTagged(addr: Address, value: Value, tag: OutputDatum): Boolean
Extension method from TxInfo

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
Extension method from TxInfo

Attributes

Returns

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

def isSignedByAny(keys: List[PubKeyHash]): Boolean
Extension method from TxInfo

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
Extension method from TxInfo

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 < 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
Extension method from TxInfo

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
Extension method from TxInfo

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) <= deadline, "too late").

Pairs with TxBuilder.validTo.

Attributes

def valuePaidTo(addr: Address): Value
Extension method from TxInfo

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

Extension method from TxInfo

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

Deprecated methods

def findOwnDatum(datumHash: DatumHash): Option[Datum]
Extension method from TxInfo

Deprecated spelling of findDatum; original body kept.

Deprecated spelling of findDatum; original body kept.

Attributes

Deprecated
[Since version 1.1.1] use findDatum
Extension method from TxInfo

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
Extension method from TxInfo

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]
Extension method from TxInfo

Same as inputs.filter(pred).

Same as inputs.filter(pred).

Attributes

Deprecated
[Since version 1.1.1] use inputs.filter
Extension method from TxInfo

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]
Extension method from TxInfo

Same as outputs.filter(pred).

Same as outputs.filter(pred).

Attributes

Deprecated
[Since version 1.1.1] use outputs.filter
Extension method from TxInfo

Deprecated spelling of findOutputsByCredential; original body kept.

Deprecated spelling of findOutputsByCredential; original body kept.

Attributes

Deprecated
[Since version 1.1.1] use findOutputsByCredential
Extension method from TxInfo

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
Extension method from TxInfo

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

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product