TransactionBuilder

Struct TransactionBuilder 

Source
pub struct TransactionBuilder(/* private fields */);

Implementations§

Source§

impl TransactionBuilder

Source

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.

Source

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

Source

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

Source

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

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<(), JsError>

Add explicit output via a TransactionOutput object

Source

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

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<(), JsError>

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<(), JsError>

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, JsError>

does not include refunds or withdrawals

Source

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

withdrawals and refunds

Source

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

Return explicit input plus implicit input plus mint

Source

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

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

Source

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

does not include fee

Source

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

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, JsError>

Source

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

Source

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

Source

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

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, 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

Source

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

Source§

fn as_ref(&self) -> &TransactionBuilder

Converts this type into a shared reference of the (usually inferred) input type.
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
Source§

impl From<TransactionBuilder> for JsValue

Source§

fn from(value: TransactionBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<TransactionBuilder> for TransactionBuilder

Source§

fn from(native: TransactionBuilder) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for TransactionBuilder

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl Into<TransactionBuilder> for TransactionBuilder

Source§

fn into(self) -> TransactionBuilder

Converts this type into the (usually inferred) input type.
Source§

impl IntoWasmAbi for TransactionBuilder

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for TransactionBuilder

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<TransactionBuilder>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for TransactionBuilder

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for TransactionBuilder

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for TransactionBuilder

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<TransactionBuilder>

The type that holds the reference to 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§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for TransactionBuilder

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<TransactionBuilder>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for TransactionBuilder

Source§

type Error = JsValue

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

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl VectorFromWasmAbi for TransactionBuilder

Source§

impl VectorIntoJsValue for TransactionBuilder

Source§

impl VectorIntoWasmAbi for TransactionBuilder

Source§

impl WasmDescribe for TransactionBuilder

Source§

impl WasmDescribeVector for TransactionBuilder

Source§

impl SupportsConstructor for TransactionBuilder

Source§

impl SupportsInstanceProperty for TransactionBuilder

Source§

impl SupportsStaticProperty for TransactionBuilder

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> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
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