scalus.cardano.txbuilder
Members list
Type members
Classlikes
Utilities for handling change outputs in transaction balancing.
Utilities for handling change outputs in transaction balancing.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Change.type
Datums in UTxOs can be stored in two forms: inline datums or datum hashes. When there's a hash, we need to provide a datum corresponding to this hash, which can be done by either providing the value literally, or using a reference input where it is stored inline. The latter is not supported, since we haven't seen it in the wild - you can work with the datum of a reference/other input directly. Please open an issue if you need it.
Datums in UTxOs can be stored in two forms: inline datums or datum hashes. When there's a hash, we need to provide a datum corresponding to this hash, which can be done by either providing the value literally, or using a reference input where it is stored inline. The latter is not supported, since we haven't seen it in the wild - you can work with the datum of a reference/other input directly. Please open an issue if you need it.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object DatumInlinedclass DatumValue
Inline datum whose value is computed from the final transaction.
Inline datum whose value is computed from the final transaction.
Registered when TransactionBuilderStep.SendWithDatumBuilder is processed. After all steps are processed, replaceDelayedDatums invokes the builder and patches the placeholder output at outputIndex.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Redeemer whose value is computed from the final transaction.
Redeemer whose value is computed from the final transaction.
Registered when a spend/mint step receives a Transaction => Data builder. After all steps are processed, replaceDelayedRedeemers invokes the builder with the sorted Transaction and patches the placeholder.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Redeemer that was detached from a transaction. Contains just enough info for it to be re-attached again, if a transaction needs a redeemer for some action.
Redeemer that was detached from a transaction. Contains just enough info for it to be re-attached again, if a transaction needs a redeemer for some action.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A transaction with redeemers detached.
A transaction with redeemers detached.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Witnesses for native scripts.
Witnesses for native scripts.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait SpendWitnesstrait Witnessclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
NativeScriptWitness.type
Use this value to indicate there will be a signature. The corresponding verification key hash will be tracked automatically in the context.
Use this value to indicate there will be a signature. The corresponding verification key hash will be tracked automatically in the context.
Attributes
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait SpendWitnesstrait Witnessclass Objecttrait Matchableclass AnyShow all
- Self type
-
PubKeyWitness.type
Internal error indicating a redeemer could not be attached to any transaction component.
Internal error indicating a redeemer could not be attached to any transaction component.
This error occurs when a detached redeemer's purpose does not match any input, mint, withdrawal, certificate, vote, or proposal in the transaction. This typically indicates an internal inconsistency in the transaction builder - a redeemer was tracked but its corresponding transaction component was removed or never added.
Value parameters
- detachedRedeemer
-
the redeemer that could not be attached, containing its data and purpose
- steps
-
the sequence of transaction builder steps that were processed
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RedeemerManagement.type
Contains a value that a redeemer corresponds to. Allows finding a redeemer index, given a transaction contains the value.
Contains a value that a redeemer corresponds to. Allows finding a redeemer index, given a transaction contains the value.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
RedeemerPurpose.type
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Specifies how the transaction should find the source code for the script.
Specifies how the transaction should find the source code for the script.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object NativeScriptAttachedclass NativeScriptValueobject PlutusScriptAttachedclass PlutusScriptValue
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ScriptSource.type
These are the sum type for any errors that may occur during different phases and that can be returned thrown by a higher-level TxBuilder
These are the sum type for any errors that may occur during different phases and that can be returned thrown by a higher-level TxBuilder
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
- Known subtypes
Base trait for errors that occur during transaction building step processing.
Base trait for errors that occur during transaction building step processing.
Each error captures the specific TransactionBuilderStep that caused the failure, allowing users to identify which operation in their transaction building sequence failed. The explain method provides a human-readable description of the error.
Attributes
- See also
-
TransactionBuilder.build for the main entry point that may return these errors
SomeBuildError.SomeStepError for how step errors are wrapped in the build result
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class AttachedScriptNotFoundclass CollateralNotPubKeyclass DatumComputationFailedclass DatumIsMissingclass DatumWitnessNotProvidedclass FeeAlreadySetclass IncorrectDatumHashclass IncorrectScriptHashclass InputAlreadyExistsclass RedeemerIndexingErrorclass ResolvedUtxosIncoherenceclass ScriptResolutionErrorclass UnneededSpoVoteWitnessclass WrongCredentialTypeclass WrongNetworkIdclass WrongOutputTypeShow all
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait SpendWitnesstrait Witnessclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TransactionBuilder.type
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class AddCollateralclass Feeclass IssueCertificateclass Mintclass ModifyAuxiliaryDataclass ReferenceOutputclass RequireSignatureclass Sendclass SendWithDatumBuilderclass SetCollateralReturnclass Spendclass SubmitProposalclass SubmitVotingProcedureclass ValidityEndSlotclass ValidityStartSlotclass WithdrawRewardsShow all
Steps to build the transaction:
Steps to build the transaction:
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TransactionEditor.type
JVM TransactionSigner that uses JvmEd25519Signer directly.
JVM TransactionSigner that uses JvmEd25519Signer directly.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TransactionSigner.type
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Transaction balancing error types.
Transaction balancing error types.
These errors can occur during the transaction balancing process, which iteratively adjusts fees and change outputs until the transaction is balanced (consumed == produced).
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A high-level, fluent API for building Cardano transactions.
A high-level, fluent API for building Cardano transactions.
TxBuilder provides a convenient way to construct transactions by chaining method calls. It handles input selection, output creation, script attachment, minting, and transaction finalization including fee calculation and change handling.
TxBuilder is purely functional; each method returns a new instance with the updated state. The complete method is the only one that performs effects (querying UTXOs from a provider).
==Platform Support==
TxBuilder supports both JVM and JavaScript platforms:
complete(provider, sponsor): ReturnsFuture[TxBuilder]. Available on all platforms.complete(provider, sponsor, timeout): JVM-only blocking version with timeout parameter.
On JVM, you can also use the await extension method on Future:
import scalus.cardano.txbuilder.await
builder.complete(provider, sponsor).await()
==Usage==
// Cross-platform - async (returns Future)
val txFuture = TxBuilder(env)
.payTo(recipientAddress, Value.ada(10))
.complete(provider, sponsorAddress)
.map(_.sign(signer).transaction)
// JVM-only - blocking with timeout
import scala.concurrent.duration.*
val tx = TxBuilder(env)
.payTo(recipientAddress, Value.ada(10))
.complete(provider, sponsorAddress, 30.seconds)
.sign(signer)
.transaction
Value parameters
- attachedData
-
datum values to be included in the transaction witness set
- changeOutputIndex
-
index of the explicit change output (set by changeTo), or None for implicit change
- context
-
the current transaction builder context
- env
-
the environment containing protocol parameters, network info, and slot configuration
- evaluator
-
the Plutus script evaluator used for script validation
- steps
-
accumulated transaction building steps
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Base exception for all TxBuilder errors.
Base exception for all TxBuilder errors.
This sealed hierarchy provides typed exceptions for different failure modes in TxBuilder, enabling programmatic error handling while remaining backwards compatible with RuntimeException.
Attributes
- Companion
- object
- Supertypes
-
class RuntimeExceptionclass Exceptionclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
Attributes
- Companion
- class
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
TxBuilderException.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
A witness to conduct an authorized operation on-chain. This could be spending an input, minting, rewarding, governance ops, certificate ops, etc.
A witness to conduct an authorized operation on-chain. This could be spending an input, minting, rewarding, governance ops, certificate ops, etc.
The only ways to do this as of writing (2025-10-03) are
- PubKey
- Native Script
- Plutus Script
The types include all additional data required to authorize the operation.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Deprecated classlikes
Tracks a pubkey hash expected to sign the transaction, used for fee estimation.
Tracks a pubkey hash expected to sign the transaction, used for fee estimation.
To add on-chain required signers, use TransactionBuilderStep.RequireSignature instead.
Attributes
- Deprecated
-
[Since version 0.15.1]Use TxBuilder.requireSignature() instead - Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Types
Witness type for minting, certificates, withdrawals, and voting operations.
Witness type for minting, certificates, withdrawals, and voting operations.
Supports both native scripts and Plutus scripts. Use the factory methods on the companion objects to create witnesses:
import TwoArgumentPlutusScriptWitness.*
val plutusWitness = attached(script, redeemer)
val refWitness = reference(redeemer)
import NativeScriptWitness.*
val nativeWitness = attached(nativeScript)
Attributes
Value members
Concrete methods
add at most 256 keys
add at most 256 keys
Attributes
Append an element to a sequence, returning distinct values only and preserving the order of elements.
Append an element to a sequence, returning distinct values only and preserving the order of elements.
Attributes
remove at most 256 keys, must be used in conjunction with addDummyVKeys
remove at most 256 keys, must be used in conjunction with addDummyVKeys
Attributes
Creates a TxBuilder using a context CardanoInfo.
Creates a TxBuilder using a context CardanoInfo.
Example:
given CardanoInfo = CardanoInfo.mainnet
val builder = txBuilder // Uses the given CardanoInfo