pub struct TransactionBuilder { /* private fields */ }
Implementations
sourceimpl TransactionBuilder
impl TransactionBuilder
sourcepub fn select_utxos(
&mut self,
strategy: CoinSelectionStrategyCIP2
) -> Result<(), JsError>
pub fn select_utxos(
&mut self,
strategy: CoinSelectionStrategyCIP2
) -> Result<(), JsError>
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.
pub fn add_input(&mut self, result: &InputBuilderResult)
pub fn add_utxo(&mut self, result: &InputBuilderResult)
sourcepub fn fee_for_input(&self, result: &InputBuilderResult) -> Result<Coin, JsError>
pub fn fee_for_input(&self, result: &InputBuilderResult) -> Result<Coin, JsError>
calculates how much the fee would increase if you added a given output
pub fn add_reference_input(&mut self, utxo: &TransactionUnspentOutput)
sourcepub fn add_output(
&mut self,
builder_result: &SingleOutputBuilderResult
) -> Result<(), JsError>
pub fn add_output(
&mut self,
builder_result: &SingleOutputBuilderResult
) -> Result<(), JsError>
Add explicit output via a TransactionOutput object
sourcepub fn fee_for_output(
&self,
builder: &SingleOutputBuilderResult
) -> Result<Coin, JsError>
pub fn fee_for_output(
&self,
builder: &SingleOutputBuilderResult
) -> Result<Coin, JsError>
calculates how much the fee would increase if you added a given output
pub fn set_fee(&mut self, fee: &Coin)
pub fn set_ttl(&mut self, ttl: &BigNum)
pub fn set_validity_start_interval(&mut self, validity_start_interval: &BigNum)
pub fn get_certs(&self) -> Option<Certificates>
pub fn add_cert(&mut self, result: &CertificateBuilderResult)
pub fn get_withdrawals(&self) -> Option<Withdrawals>
pub fn add_withdrawal(&mut self, result: &WithdrawalBuilderResult)
pub fn get_auxiliary_data(&self) -> Option<AuxiliaryData>
pub fn set_auxiliary_data(&mut self, new_aux_data: &AuxiliaryData)
pub fn add_auxiliary_data(&mut self, new_aux_data: &AuxiliaryData)
pub fn add_mint(&mut self, result: &MintBuilderResult)
pub fn new(cfg: &TransactionBuilderConfig) -> Self
pub fn add_collateral(
&mut self,
result: &InputBuilderResult
) -> Result<(), JsError>
pub fn collateral(&self) -> Option<TransactionInputs>
pub fn add_required_signer(&mut self, hash: &Ed25519KeyHash)
pub fn required_signers(&self) -> Option<RequiredSigners>
pub fn set_network_id(&mut self, network_id: NetworkId)
pub fn network_id(&self) -> Option<NetworkId>
sourcepub fn get_explicit_input(&self) -> Result<Value, JsError>
pub fn get_explicit_input(&self) -> Result<Value, JsError>
does not include refunds or withdrawals
sourcepub fn get_implicit_input(&self) -> Result<Value, JsError>
pub fn get_implicit_input(&self) -> Result<Value, JsError>
withdrawals and refunds
sourcepub fn get_total_input(&self) -> Result<Value, JsError>
pub fn get_total_input(&self) -> Result<Value, JsError>
Return explicit input plus implicit input plus mint
sourcepub fn get_total_output(&self) -> Result<Value, JsError>
pub fn get_total_output(&self) -> Result<Value, JsError>
Return explicit output plus implicit output plus burn (does not consider fee directly)
sourcepub fn get_explicit_output(&self) -> Result<Value, JsError>
pub fn get_explicit_output(&self) -> Result<Value, JsError>
does not include fee
pub fn get_deposit(&self) -> Result<Coin, JsError>
pub fn get_fee_if_set(&self) -> Option<Coin>
sourcepub fn add_change_if_needed(
&mut self,
address: &Address
) -> Result<bool, JsError>
pub fn add_change_if_needed(
&mut self,
address: &Address
) -> Result<bool, JsError>
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
pub fn set_collateral_return(&mut self, output: &TransactionOutput)
pub fn full_size(&self) -> Result<usize, JsError>
pub fn output_sizes(&self) -> Vec<usize>
sourcepub fn build(&self) -> Result<TxRedeemerBuilder, JsError>
pub fn build(&self) -> Result<TxRedeemerBuilder, JsError>
Builds the transaction and moves to the next step where any real witness can be added NOTE: is_valid set to true
sourcepub fn min_fee(&self) -> Result<Coin, JsError>
pub fn min_fee(&self) -> Result<Coin, JsError>
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
sourceimpl Clone for TransactionBuilder
impl Clone for TransactionBuilder
sourcefn clone(&self) -> TransactionBuilder
fn clone(&self) -> TransactionBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for TransactionBuilder
impl Send for TransactionBuilder
impl Sync for TransactionBuilder
impl Unpin for TransactionBuilder
impl UnwindSafe for TransactionBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more