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: SortedMap[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

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

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

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

Value parameters

datumHash

the hash of the datum to search for

Attributes

Returns

Some(Datum) if the datum is found in either transaction outputs or datum lookup map, None otherwise

Example
val txInfo = TxInfo(...)
val datumHash = DatumHash(...)
val maybeDatum = txInfo.findOwnDatum(datumHash)
// Returns Some(Datum) if the datumHash exists in txInfo.data or txInfo.outputs
// Returns None if the datumHash is not found
Extension method from TxInfo

Finds a transaction input in this transaction's inputs by its output reference.

Finds a transaction input in this transaction's inputs by its output reference.

Value parameters

outRef

the transaction output reference to search for

Attributes

Returns

Some(TxInInfo) if the input is found, None otherwise

Example
val txInfo = TxInfo(...)
val outRef = TxOutRef(txId, 0)
val maybeInput = txInfo.findOwnInput(outRef)
// Returns Some(TxInInfo) if the outRef exists in txInfo.inputs
// Returns None if the outRef is not found
inline def findOwnInputOrFail(outRef: TxOutRef, inline message: String = ...): TxInInfo
Extension method from TxInfo

Finds a transaction input in this transaction's inputs by its output reference. Fails with the provided message if the input is not found.

Finds a transaction input in this transaction's inputs by its output reference. Fails with the provided message if the input is not found.

Value parameters

message

the error message to use if the input is not found

outRef

the transaction output reference to search for

Attributes

Returns

TxInInfo if the input is found

Example
val txInfo = TxInfo(...)
val outRef = TxOutRef(txId, 0)
val input = txInfo.findOwnInputOrFail(outRef, "Input not found")
// Returns TxInInfo if the outRef exists in txInfo.inputs
// Fails with "Input not found" if the outRef is not found
def findOwnInputs(pred: TxInInfo => Boolean): List[TxInInfo]
Extension method from TxInfo

Finds all transaction inputs in this transaction that match a given predicate.

Finds all transaction inputs in this transaction that match a given predicate.

Value parameters

pred

the predicate function to test each input

Attributes

Returns

List of transaction inputs that satisfy the predicate

Example
val txInfo = TxInfo(...)
val inputs = txInfo.findOwnInputs(in => in.resolved.value.lovelace > 1000000)
// Returns List[TxInInfo] containing all inputs with more than 1 ADA
// Returns empty List if no inputs match the predicate
Extension method from TxInfo

Finds all transaction inputs in this transaction that are locked by a specific credential.

Finds all transaction inputs in this transaction that are locked by a specific credential.

Value parameters

cred

the credential to search for in input addresses

Attributes

Returns

List of transaction inputs whose resolved addresses match the given credential

Example
val txInfo = TxInfo(...)
val credential = Credential.PubKey(pubKeyHash)
val inputs = txInfo.getOwnInputsByCredential(credential)
// Returns List[TxInInfo] containing all inputs locked by the credential
// Returns empty List if no matching inputs are found
def findOwnOutputs(pred: TxOut => Boolean): List[TxOut]
Extension method from TxInfo

Finds all transaction outputs in this transaction that match a given predicate.

Finds all transaction outputs in this transaction that match a given predicate.

Value parameters

pred

the predicate function to test each output

Attributes

Returns

List of transaction outputs that satisfy the predicate

Example
val txInfo = TxInfo(...)
val outputs = txInfo.findOwnOutputs(out => out.value.lovelace > 1000000)
// Returns List[TxOut] containing all outputs with more than 1 ADA
// Returns empty List if no outputs match the predicate
Extension method from TxInfo

Finds all transaction outputs in this transaction that are locked by a specific credential.

Finds all transaction outputs in this transaction that are locked by a specific credential.

Value parameters

cred

the credential to search for in output addresses

Attributes

Returns

List of transaction outputs whose addresses match the given credential

Example
val txInfo = TxInfo(...)
val credential = Credential.PubKey(pubKeyHash)
val outputs = txInfo.getOwnOutputsByCredential(credential)
// Returns List[TxOut] containing all outputs locked by the credential
// Returns empty List if no matching outputs are found
Extension method from TxInfo

Finds all transaction outputs that are locked by a specific validator script.

Finds all transaction outputs that are locked by a specific validator script.

Value parameters

scriptHash

the hash of the validator script to search for

Attributes

Returns

List of transaction outputs that are locked by the given validator script

Example
val txInfo = TxInfo(...)
val validatorHash = ValidatorHash(...)
val scriptOutputs = txInfo.findOwnScriptOutputs(validatorHash)
// Returns List[TxOut] containing all outputs locked by the validator script
// Returns empty List if no matching outputs are found
def getValidityStartTime: BigInt
Extension method from TxInfo

Extracts the start time from the transaction's validity interval.

Extracts the start time from the transaction's validity interval.

Returns the earliest valid time (lower bound) of the transaction's validity range. If the validity range has no finite lower bound (e.g., unbounded or negative infinity), returns 0.

Attributes

Returns

the start time as PosixTime if the validity range has a finite lower bound, otherwise 0

Example
val txInfo = TxInfo(...)
val startTime = txInfo.getValidityStartTime
// Returns the PosixTime of the validity range's lower bound
// Returns BigInt(0) if the lower bound is infinite or unbounded
def isSignedBy(pubKeyHash: PubKeyHash): Boolean
Extension method from TxInfo

Attributes

Returns

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

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product