TxInfo

scalus.ledger.api.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

Extensions

extension (self: TxInfo)
def findOwnDatum(datumHash: DatumHash): Option[Datum]

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

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

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]

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

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]

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

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

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

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

Attributes

Returns

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