TransactionBuilder class

This builder manages the details of assembling a balanced transaction, including fee calculation, change callculation, time-to-live constraints (ttl) and signing.

Using the build() and sign() methods, transactions can be built manually. However, you have to ensure the inputs, outputs and fee add up to zero (i.e. the isBalanced property should be true). Using the buildAndSign() method automates this process given a recipient and amount.

Coin selection is not currently handled internally, see CoinSelectionAlgorithm.

Constructors

TransactionBuilder()

Properties

defaultTtlDelta int
Added to current slot to get ttl. Currently 900sec or 15min.
final
hashCode int
The hash code for this object.
no setterinherited
isBalanced bool
Check if inputs and outputs including fee, add up to zero or balance out.
no setter
isCurrentSlotUnsetOrStale bool
return true if the ttl-focused current slot is stale or needs to be refreshed based on the current time and staleSlotCuttoff.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
staleSlotCuttoff Duration
How often to check current slot. If 1 minute old, update
final

Methods

blockchainAdapter(BlockchainAdapter blockchainAdapter) → void
build() ShelleyTransaction
simple build - assemble transaction without any validation
buildAndSign({bool mustBalance = true}) Future<Result<ShelleyTransaction, String>>
Automates building a valid, signed transaction inlcuding checking required inputs, calculating ttl, fee and change.
calculateMinFee({required ShelleyTransaction tx, Coin minFee = 0}) Coin
Because transaction size effects fees, this method should be called last, after all other ShelleyTransactionBody properties are set. if minFee is set, then this determines the lower minimum fee bound.
calculateTimeToLive() Future<Result<int, String>>
Set the time range in which this transaction is valid. Time-to-live (TTL) - represents a slot, or deadline by which a transaction must be submitted. The TTL is an absolute slot number, rather than a relative one, which means that the ttl value should be greater than the current slot number. A transaction becomes invalid once its ttl expires. Currently each slot is one second and each epoch currently includes 432,000 slots (5 days).
changeAddress(ShelleyAddress changeAddress) → void
currentSlot(int currentSlot) → void
fee(Coin fee) → void
input({required String transactionId, required int index}) → void
inputs(List<ShelleyTransactionInput> inputs) → void
linearFee(LinearFee linearFee) → void
metadata(CBORMetadata metadata) → void
metadataHash(List<int>? metadataHash) → void
minFee(Coin minFee) → void
minFeeFunction(MinFeeFunction feeFunction) → void
mint(ShelleyMultiAsset mint) → void
mints(List<ShelleyMultiAsset> mint) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
output({ShelleyAddress? shelleyAddress, String? address, MultiAssetBuilder? multiAssetBuilder, ShelleyValue? value, bool autoAddMinting = true}) → void
build a single ShelleyTransactionOutput, handle complex output construction
sign() ShelleyTransaction
manually sign transacion and set single witnessSet.
signAndBuildWitnesses(Map<ShelleyAddress, Bip32KeyPair> utxoKeyPairs, List<int> signature) ShelleyTransactionWitnessSet
toAddress(ShelleyAddress toAddress) → void
toString() String
A string representation of this object.
inherited
ttl(int ttl) → void
txInput(ShelleyTransactionInput input) → void
txOutput(ShelleyTransactionOutput output) → void
validityStartInterval(int validityStartInterval) → void
value(ShelleyValue value) → void
wallet(Wallet wallet) → void
witnessSet(ShelleyTransactionWitnessSet witnessSet) → void

Operators

operator ==(Object other) bool
The equality operator.
inherited