Struct TransactionBuilder

Source
pub struct TransactionBuilder<'a, C, T = ()> { /* private fields */ }
Expand description

A builder for a transaction.

Implementations§

Source§

impl<'a, C: Deref<Target = impl Signer> + Clone> TransactionBuilder<'a, C>

Source

pub fn new(program_id: Pubkey, cfg: &'a Config<C>) -> Self

Create a new transaction builder.

Source

pub fn merge(self, other: Self) -> Self

Merge other TransactionBuilder. The rpc fields will be empty after merging, i.e., take_rpc will return None.

§Panics

Return if there are any errors.

§Notes
  • All options including cluster, commiment and program_id will still be the same of self after merging.
Source

pub fn try_merge(&mut self, other: &mut Self) -> Result<()>

Merge other TransactionBuilder. The rpc fields will be empty after merging, i.e., take_rpc will return None.

§Errors

Return error if the payers are not the same.

§Notes
  • When success, the other will become a empty TransactionBuilder.
  • All options including cluster, commiment, and program_id will still be the same of self after merging.
Source

pub fn into_bundle_with_options( self, options: BundleOptions, ) -> Result<BundleBuilder<'a, C>>

Convert into a BundleBuilder with the given options.

Source

pub fn into_bundle(self) -> Result<BundleBuilder<'a, C>>

Convert into a BundleBuilder.

Source§

impl<'a, C: Deref<Target = impl Signer> + Clone, T> TransactionBuilder<'a, C, T>

Source

pub fn payer<C2>(self, payer: C2) -> TransactionBuilder<'a, C2, T>

Set payer.

Source

pub fn get_payer(&self) -> Pubkey

Get the pubkey of the payer.

Source

pub fn cluster(self, url: impl AsRef<str>) -> Result<Self>

Set cluster.

Source

pub fn options(self, options: CommitmentConfig) -> Self

Set commiment options.

Source

pub fn signer(self, signer: &'a dyn Signer) -> Self

Add a signer to the signer list.

Source

pub fn owned_signer(self, signer: impl Signer + Clone + 'static) -> Self

Add a owned sigenr to the signer list.

Source

pub fn program(self, program_id: Pubkey) -> Self

Set program id.

Source

pub fn accounts(self, accounts: Vec<AccountMeta>) -> Self

Append accounts for the main instruction.

Source

pub fn anchor_accounts(self, accounts: impl ToAccountMetas) -> Self

Append accounts for the main instruction.

Source

pub fn args(self, args: Vec<u8>) -> Self

Set arguments for the main instruction.

Source

pub fn anchor_args(self, args: impl InstructionData) -> Self

Set arguments for the main instruction.

Source

pub fn compute_budget(self, budget: ComputeBudget) -> Self

Set compute budget.

Source

pub fn compute_budget_mut(&mut self) -> &mut ComputeBudget

Get mutable reference to the compute budget.

Source

pub fn take_instruction(&mut self) -> Option<Instruction>

Take and construct the “main” instruction if present.

Source

pub fn instructions(&self) -> Vec<Instruction>

Construct all instructions.

Source

pub fn instructions_with_options( &self, without_compute_budget: bool, compute_unit_price_micro_lamports: Option<u64>, ) -> Vec<Instruction>

Construct all instructions with options.

Source

pub fn get_output(&self) -> &T

Get the output.

Source

pub fn swap_output<U>(self, output: U) -> (TransactionBuilder<'a, C, U>, T)

Set the output and return the previous.

Source

pub fn output<U>(self, output: U) -> TransactionBuilder<'a, C, U>

Set the output.

Source

pub fn clear_output(self) -> TransactionBuilder<'a, C, ()>

Clear the output.

Source

pub fn pre_instruction(self, ix: Instruction) -> Self

Insert an instruction before the “main” instruction.

Source

pub fn pre_instructions(self, ixs: Vec<Instruction>) -> Self

Insert instructions before the “main” instruction.

Source

pub fn lookup_table(self, account: AddressLookupTableAccount) -> Self

Insert an address lookup table account.

Source

pub fn lookup_tables( self, tables: impl IntoIterator<Item = (Pubkey, Vec<Pubkey>)>, ) -> Self

Insert many address lookup tables.

Source

pub fn message_with_blockhash_and_options( &self, latest_hash: Hash, without_compute_budget: bool, compute_unit_price_micro_lamports: Option<u64>, ) -> Result<VersionedMessage>

Get versioned message with the given hash and options.

Source

pub async fn message_with_options( &self, without_compute_budget: bool, compute_unit_price_micro_lamports: Option<u64>, ) -> Result<VersionedMessage>

Get versioned message with options.

Source

pub fn signed_transaction_with_blockhash_and_options( &self, latest_hash: Hash, without_compute_budget: bool, compute_unit_price_micro_lamports: Option<u64>, ) -> Result<VersionedTransaction>

Get signed transaction with blockhash and options.

Source

pub async fn signed_transaction_with_options( &self, without_compute_budget: bool, compute_unit_price_micro_lamports: Option<u64>, ) -> Result<VersionedTransaction>

Get signed transactoin with options.

Source

pub async fn send_with_options( &self, without_compute_budget: bool, compute_unit_price_micro_lamports: Option<u64>, config: RpcSendTransactionConfig, ) -> Result<WithSlot<Signature>>

Sign and send the transaction with options.

Source

pub async fn send_without_preflight(self) -> Result<Signature>

Build and send the transaction without preflight.

Source

pub async fn send(self) -> Result<Signature>

Build and send the transaction with default options.

Source

pub fn get_complete_lookup_table(&self) -> HashSet<Pubkey>

Get complete lookup table.

Source

pub fn get_luts(&self) -> &HashMap<Pubkey, Vec<Pubkey>>

Get luts.

Source

pub fn transaction_size(&self, is_versioned_transaction: bool) -> usize

Estimates the size of the result transaction.

See transaction_size() for more information.

Source

pub async fn estimate_execution_fee( &self, _client: &RpcClient, compute_unit_price_micro_lamports: Option<u64>, ) -> Result<u64>

Estimated the execution fee of the result transaction.

Trait Implementations§

Source§

impl<'a, C: Clone, T: Clone> Clone for TransactionBuilder<'a, C, T>

Source§

fn clone(&self) -> TransactionBuilder<'a, C, T>

Returns a copy 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<'a, C: Deref<Target = impl Signer> + Clone> MakeBundleBuilder<'a, C> for TransactionBuilder<'a, C>

Source§

async fn build_with_options( &mut self, options: BundleOptions, ) -> Result<BundleBuilder<'a, C>>

Build with options.
Source§

fn build(&mut self) -> impl Future<Output = Result<BundleBuilder<'a, C>>>

Build.

Auto Trait Implementations§

§

impl<'a, C, T> Freeze for TransactionBuilder<'a, C, T>
where T: Freeze, C: Freeze,

§

impl<'a, C, T = ()> !RefUnwindSafe for TransactionBuilder<'a, C, T>

§

impl<'a, C, T = ()> !Send for TransactionBuilder<'a, C, T>

§

impl<'a, C, T = ()> !Sync for TransactionBuilder<'a, C, T>

§

impl<'a, C, T> Unpin for TransactionBuilder<'a, C, T>
where T: Unpin, C: Unpin,

§

impl<'a, C, T = ()> !UnwindSafe for TransactionBuilder<'a, C, T>

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<'a, C, T> MakeBundleBuilderExt<'a, C> for T
where T: MakeBundleBuilder<'a, C> + ?Sized,

Source§

fn surround(self) -> Surround<'a, C, Self>
where Self: Sized,

Surround the current builder.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T