Skip to main content

TransactionBuilder

Struct TransactionBuilder 

Source
pub struct TransactionBuilder { /* private fields */ }

Implementations§

Source§

impl TransactionBuilder

Source

pub fn select_utxos( &mut self, strategy: CoinSelectionStrategyCIP2, ) -> Result<(), TxBuilderError>

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.

Source

pub fn add_input( &mut self, result: InputBuilderResult, ) -> Result<(), TxBuilderError>

Source

pub fn add_utxo(&mut self, result: InputBuilderResult)

Source

pub fn fee_for_input( &self, result: &InputBuilderResult, ) -> Result<Coin, TxBuilderError>

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

Source

pub fn add_reference_input(&mut self, utxo: TransactionUnspentOutput)

Add a reference input. Must be called BEFORE adding anything (inputs, certs, etc) that refer to this reference input.

Source

pub fn add_output( &mut self, builder_result: SingleOutputBuilderResult, ) -> Result<(), TxBuilderError>

Add explicit output via a TransactionOutput object

Source

pub fn fee_for_output( &self, builder: &SingleOutputBuilderResult, ) -> Result<Coin, TxBuilderError>

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

Source

pub fn set_fee(&mut self, fee: Coin)

Source

pub fn set_donation(&mut self, donation: Coin)

Source

pub fn set_current_treasury_value(&mut self, current_treasury_value: Coin)

Source

pub fn set_ttl(&mut self, ttl: Slot)

Source

pub fn set_validity_start_interval(&mut self, validity_start_interval: Slot)

Source

pub fn add_cert(&mut self, result: CertificateBuilderResult)

Source

pub fn add_proposal(&mut self, result: ProposalBuilderResult)

Source

pub fn add_vote(&mut self, result: VoteBuilderResult)

Source

pub fn get_withdrawals(&self) -> Option<Withdrawals>

Source

pub fn add_withdrawal(&mut self, result: WithdrawalBuilderResult)

Source

pub fn get_auxiliary_data(&self) -> Option<AuxiliaryData>

Source

pub fn set_auxiliary_data(&mut self, new_aux_data: AuxiliaryData)

Source

pub fn add_auxiliary_data(&mut self, new_aux_data: AuxiliaryData)

Source

pub fn add_mint( &mut self, result: MintBuilderResult, ) -> Result<(), TxBuilderError>

Source

pub fn get_mint(&self) -> Option<Mint>

Returns a copy of the current mint state in the builder

Source

pub fn new(cfg: TransactionBuilderConfig) -> Self

Source

pub fn add_collateral( &mut self, result: InputBuilderResult, ) -> Result<(), TxBuilderError>

Source

pub fn add_required_signer(&mut self, hash: Ed25519KeyHash)

Source

pub fn set_network_id(&mut self, network_id: NetworkId)

Source

pub fn network_id(&self) -> Option<NetworkId>

Source

pub fn get_explicit_input(&self) -> Result<Value, TxBuilderError>

does not include refunds or withdrawals

Source

pub fn get_implicit_input(&self) -> Result<Value, TxBuilderError>

withdrawals and refunds

Source

pub fn get_total_input(&self) -> Result<Value, TxBuilderError>

Return explicit input plus implicit input plus mint

Source

pub fn get_total_output(&self) -> Result<Value, TxBuilderError>

Return explicit output plus implicit output plus burn/donation (does not consider fee directly)

Source

pub fn get_explicit_output(&self) -> Result<Value, TxBuilderError>

does not include fee

Source

pub fn get_deposit(&self) -> Result<Coin, TxBuilderError>

Source

pub fn get_fee_if_set(&self) -> Option<Coin>

Source

pub fn set_collateral_return(&mut self, output: TransactionOutput)

Source

pub fn full_size(&self) -> Result<usize, TxBuilderError>

Source

pub fn output_sizes(&self) -> Vec<usize>

Source

pub fn build_for_evaluation( &self, algo: ChangeSelectionAlgo, change_address: &Address, ) -> Result<TxRedeemerBuilder, TxBuilderError>

Builds the transaction and moves to the next step redeemer units can be added and a draft tx can be evaluated NOTE: is_valid set to true

Source

pub fn build( &mut self, algo: ChangeSelectionAlgo, change_address: &Address, ) -> Result<SignedTxBuilder, TxBuilderError>

Builds the transaction and moves to the next step where any real witness can be added NOTE: is_valid set to true

Source

pub fn set_exunits(&mut self, redeemer: RedeemerWitnessKey, ex_units: ExUnits)

used to override the exunit values initially provided when adding inputs

Source

pub fn min_fee(&self, script_calulation: bool) -> Result<Coin, TxBuilderError>

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§

Source§

impl Clone for TransactionBuilder

Source§

fn clone(&self) -> TransactionBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TransactionBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V