pub struct TransactionBuilder { /* private fields */ }

Implementations§

This automatically selects and adds inputs from {inputs} consisting of just enough to cover the outputs that have already been added. This should be called after adding all certs/outputs/etc and will be an error otherwise. Uses CIP2: https://github.com/cardano-foundation/CIPs/blob/master/CIP-0002/CIP-0002.md Adding a change output must be called after via TransactionBuilder::add_change_if_needed() This function, diverging from CIP2, takes into account fees and will attempt to add additional inputs to cover the minimum fees. This does not, however, set the txbuilder’s fee.

This function will set the collateral-return value and then auto-calculate and assign the total collateral coin value. Will raise an error in case no collateral inputs are set or in case the total collateral value will have any assets in it except coin.

This function will set the total-collateral coin and then auto-calculate and assign the collateral return value. Will raise an error in case no collateral inputs are set. The specified address will be the received of the collateral return

👎Deprecated since 10.2.0: Use .set_inputs

We have to know what kind of inputs these are to know what kind of mock witnesses to create since

  1. mock witnesses have different lengths depending on the type which changes the expecting fee
  2. Witnesses are a set so we need to get rid of duplicates to avoid over-estimating the fee
👎Deprecated since 10.2.0: Use .set_inputs

This method adds the input to the builder BUT leaves a missing spot for the witness native script

After adding the input with this method, use .add_required_native_input_scripts and .add_required_plutus_input_scripts to add the witness scripts

Or instead use .add_native_script_input and .add_plutus_script_input to add inputs right along with the script, instead of the script hash

👎Deprecated since 10.2.0: Use .set_inputs

This method will add the input to the builder and also register the required native script witness

👎Deprecated since 10.2.0: Use .set_inputs

This method will add the input to the builder and also register the required plutus witness

👎Deprecated since 10.2.0: Use .set_inputs
👎Deprecated since 10.2.0: Use .set_inputs

Note that for script inputs this method will use underlying generic .add_script_input which leaves a required empty spot for the script witness (or witnesses in case of Plutus). You can use .add_native_script_input or .add_plutus_script_input directly to register the input along with the witness.

👎Deprecated since 10.2.0: Use .count_missing_input_scripts from TxInputsBuilder

Returns the number of still missing input scripts (either native or plutus) Use .add_required_native_input_scripts or .add_required_plutus_input_scripts to add the missing scripts

👎Deprecated since 10.2.0: Use .set_inputs

Try adding the specified scripts as witnesses for ALREADY ADDED script inputs Any scripts that don’t match any of the previously added inputs will be ignored Returns the number of remaining required missing witness scripts Use .count_missing_input_scripts to find the number of still missing scripts

👎Deprecated since 10.2.0: Use .set_inputs

Try adding the specified scripts as witnesses for ALREADY ADDED script inputs Any scripts that don’t match any of the previously added inputs will be ignored Returns the number of remaining required missing witness scripts Use .count_missing_input_scripts to find the number of still missing scripts

👎Deprecated since 10.2.0: Use .set_inputs

Returns a copy of the current script input witness scripts in the builder

👎Deprecated since 10.2.0: Use .set_inputs

Returns a copy of the current plutus input witness scripts in the builder. NOTE: each plutus witness will be cloned with a specific corresponding input index

calculates how much the fee would increase if you added a given output

Add explicit output via a TransactionOutput object

calculates how much the fee would increase if you added a given output

👎Deprecated since 10.1.0: Underlying value capacity of ttl (BigNum u64) bigger then Slot32. Use set_ttl_bignum instead.

!!! DEPRECATED !!! Set ttl value.

👎Deprecated since 10.1.0: Underlying value capacity of validity_start_interval (BigNum u64) bigger then Slot32. Use set_validity_start_interval_bignum instead.

!!! DEPRECATED !!! Uses outdated slot number format.

Set explicit auxiliary data via an AuxiliaryData object It might contain some metadata plus native or Plutus scripts

Set metadata using a GeneralTransactionMetadata object It will be set to the existing or new auxiliary data in this builder

Add a single metadatum using TransactionMetadatumLabel and TransactionMetadatum objects It will be securely added to existing or new metadata in this builder

Add a single JSON metadatum using a TransactionMetadatumLabel and a String It will be securely added to existing or new metadata in this builder

Add a single JSON metadatum using a TransactionMetadatumLabel, a String, and a MetadataJsonSchema object It will be securely added to existing or new metadata in this builder

👎Deprecated since 11.2.0: Mints are defining by MintBuilder now. Use .set_mint_builder() and MintBuilder instead.

!!! DEPRECATED !!! Mints are defining by MintBuilder now. Use .set_mint_builder() and MintBuilder instead. Set explicit Mint object and the required witnesses to this builder it will replace any previously existing mint and mint scripts NOTE! Error will be returned in case a mint policy does not have a matching script

👎Deprecated since 11.2.0: Mints are defining by MintBuilder now. Use .get_mint_builder() and .build() instead.

!!! DEPRECATED !!! Mints are defining by MintBuilder now. Use .get_mint_builder() and .build() instead. Returns a copy of the current mint state in the builder

Returns a copy of the current mint witness scripts in the builder

👎Deprecated since 11.2.0: Mints are defining by MintBuilder now. Use .set_mint_builder() and MintBuilder instead.

!!! DEPRECATED !!! Mints are defining by MintBuilder now. Use .set_mint_builder() and MintBuilder instead. Add a mint entry to this builder using a PolicyID and MintAssets object It will be securely added to existing or new Mint in this builder It will replace any existing mint assets with the same PolicyID

👎Deprecated since 11.2.0: Mints are defining by MintBuilder now. Use .set_mint_builder() and MintBuilder instead.

!!! DEPRECATED !!! Mints are defining by MintBuilder now. Use .set_mint_builder() and MintBuilder instead. Add a mint entry to this builder using a PolicyID, AssetName, and Int object for amount It will be securely added to existing or new Mint in this builder It will replace any previous existing amount same PolicyID and AssetName

Add a mint entry together with an output to this builder Using a PolicyID, AssetName, Int for amount, Address, and Coin (BigNum) objects The asset will be securely added to existing or new Mint in this builder A new output will be added with the specified Address, the Coin value, and the minted asset

Add a mint entry together with an output to this builder Using a PolicyID, AssetName, Int for amount, and Address objects The asset will be securely added to existing or new Mint in this builder A new output will be added with the specified Address and the minted asset The output will be set to contain the minimum required amount of Coin

does not include refunds or withdrawals

withdrawals and refunds

Return explicit input plus implicit input plus mint

Return explicit output plus deposit plus burn

does not include fee

Warning: this function will mutate the /fee/ field Make sure to call this function last after setting all other tx-body properties Editing inputs, outputs, mint, etc. after change been calculated might cause a mismatch in calculated fee versus the required fee

This method will calculate the script hash data using the plutus datums and redeemers already present in the builder along with the provided cost model, and will register the calculated value in the builder to be used when building the tx body. In case there are no plutus input witnesses present - nothing will change You can set specific hash value using .set_script_data_hash NOTE: this function will check which language versions are used in the present scripts and will assert and require for a corresponding cost-model to be present in the passed map. Only the cost-models for the present language versions will be used in the hash calculation.

Sets the specified hash value. Alternatively you can use .calc_script_data_hash to calculate the hash automatically. Or use .remove_script_data_hash to delete the previously set value

Deletes any previously set plutus data hash value. Use .set_script_data_hash or .calc_script_data_hash to set it.

Returns object the body of the new transaction Auxiliary data itself is not included You can use get_auxiliary_data or build_tx

Returns full Transaction object with the body and the auxiliary data NOTE: witness_set will contain all mint_scripts if any been added or set NOTE: is_valid set to true NOTE: Will fail in case there are any script inputs added with no corresponding witness

Similar to .build_tx() but will NOT fail in case there are missing script witnesses

warning: sum of all parts of a transaction must equal 0. You cannot just set the fee to the min value and forget about it warning: min_fee may be slightly larger than the actual minimum fee (ex: a few lovelaces) this is done to simplify the library code, but can be fixed later

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.