pub struct TransactionBuilder(/* private fields */);Implementations§
Source§impl 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) -> Result<(), JsError>
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
Sourcepub fn add_reference_input(&mut self, utxo: &TransactionUnspentOutput)
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.
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_donation(&mut self, donation: Coin)
pub fn set_current_treasury_value(&mut self, current_treasury_value: Coin)
pub fn set_ttl(&mut self, ttl: Slot)
pub fn set_validity_start_interval(&mut self, validity_start_interval: Slot)
pub fn add_cert(&mut self, result: &CertificateBuilderResult)
pub fn add_proposal(&mut self, result: ProposalBuilderResult)
pub fn add_vote(&mut self, result: VoteBuilderResult)
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) -> Result<(), JsError>
pub fn new(cfg: &TransactionBuilderConfig) -> Self
pub fn add_collateral( &mut self, result: &InputBuilderResult, ) -> Result<(), JsError>
pub fn add_required_signer(&mut self, hash: &Ed25519KeyHash)
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>
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_for_evaluation(
&self,
algo: ChangeSelectionAlgo,
change_address: &Address,
) -> Result<TxRedeemerBuilder, JsError>
pub fn build_for_evaluation( &self, algo: ChangeSelectionAlgo, change_address: &Address, ) -> Result<TxRedeemerBuilder, JsError>
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
Sourcepub fn build(
&mut self,
algo: ChangeSelectionAlgo,
change_address: &Address,
) -> Result<SignedTxBuilder, JsError>
pub fn build( &mut self, algo: ChangeSelectionAlgo, change_address: &Address, ) -> Result<SignedTxBuilder, 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 set_exunits(&mut self, redeemer: &RedeemerWitnessKey, ex_units: &ExUnits)
pub fn set_exunits(&mut self, redeemer: &RedeemerWitnessKey, ex_units: &ExUnits)
used to override the exunit values initially provided when adding inputs
Sourcepub fn min_fee(&self, script_calulation: bool) -> Result<Coin, JsError>
pub fn min_fee(&self, script_calulation: bool) -> 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
Sourcepub fn add_change_if_needed(
&mut self,
address: &Address,
include_exunits: bool,
) -> Result<bool, JsError>
pub fn add_change_if_needed( &mut self, address: &Address, include_exunits: bool, ) -> 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
Trait Implementations§
Source§impl AsRef<TransactionBuilder> for TransactionBuilder
impl AsRef<TransactionBuilder> for TransactionBuilder
Source§fn as_ref(&self) -> &TransactionBuilder
fn as_ref(&self) -> &TransactionBuilder
Source§impl Clone for TransactionBuilder
impl Clone for TransactionBuilder
Source§fn clone(&self) -> TransactionBuilder
fn clone(&self) -> TransactionBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TransactionBuilder
impl Debug for TransactionBuilder
Source§impl From<TransactionBuilder> for JsValue
impl From<TransactionBuilder> for JsValue
Source§fn from(value: TransactionBuilder) -> Self
fn from(value: TransactionBuilder) -> Self
Source§impl From<TransactionBuilder> for TransactionBuilder
impl From<TransactionBuilder> for TransactionBuilder
Source§fn from(native: TransactionBuilder) -> Self
fn from(native: TransactionBuilder) -> Self
Source§impl FromWasmAbi for TransactionBuilder
impl FromWasmAbi for TransactionBuilder
Source§impl Into<TransactionBuilder> for TransactionBuilder
impl Into<TransactionBuilder> for TransactionBuilder
Source§fn into(self) -> TransactionBuilder
fn into(self) -> TransactionBuilder
Source§impl IntoWasmAbi for TransactionBuilder
impl IntoWasmAbi for TransactionBuilder
Source§impl RefFromWasmAbi for TransactionBuilder
impl RefFromWasmAbi for TransactionBuilder
Source§type Anchor = RcRef<TransactionBuilder>
type Anchor = RcRef<TransactionBuilder>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl TryFromJsValue for TransactionBuilder
impl TryFromJsValue for TransactionBuilder
Source§impl VectorFromWasmAbi for TransactionBuilder
impl VectorFromWasmAbi for TransactionBuilder
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[TransactionBuilder]>
Source§impl VectorIntoJsValue for TransactionBuilder
impl VectorIntoJsValue for TransactionBuilder
fn vector_into_jsvalue(vector: Box<[TransactionBuilder]>) -> JsValue
Source§impl VectorIntoWasmAbi for TransactionBuilder
impl VectorIntoWasmAbi for TransactionBuilder
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[TransactionBuilder]>) -> Self::Abi
Source§impl WasmDescribeVector for TransactionBuilder
impl WasmDescribeVector for TransactionBuilder
impl SupportsConstructor for TransactionBuilder
impl SupportsInstanceProperty for TransactionBuilder
impl SupportsStaticProperty for TransactionBuilder
Auto Trait Implementations§
impl Freeze for TransactionBuilder
impl RefUnwindSafe for TransactionBuilder
impl Send for TransactionBuilder
impl Sync for TransactionBuilder
impl Unpin for TransactionBuilder
impl UnwindSafe for TransactionBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.