pub struct TransactionBatchBuilder { /* private fields */ }Expand description
Builder for creating a batch of transactions.
This builder handles:
- Automatic sequence number management
- Gas estimation
- Transaction signing
§Example
ⓘ
let batch = TransactionBatchBuilder::new()
.sender(account.address())
.starting_sequence_number(10)
.chain_id(ChainId::testnet())
.gas_unit_price(100)
.add_payload(payload1)
.add_payload(payload2)
.build_and_sign(&account)?;Implementations§
Source§impl TransactionBatchBuilder
impl TransactionBatchBuilder
Sourcepub fn sender(self, sender: AccountAddress) -> Self
pub fn sender(self, sender: AccountAddress) -> Self
Sets the sender address.
Sourcepub fn starting_sequence_number(self, seq: u64) -> Self
pub fn starting_sequence_number(self, seq: u64) -> Self
Sets the starting sequence number.
Each transaction in the batch will use an incrementing sequence number starting from this value.
Sourcepub fn gas_unit_price(self, price: u64) -> Self
pub fn gas_unit_price(self, price: u64) -> Self
Sets the gas unit price for all transactions.
Sourcepub fn max_gas_amount(self, amount: u64) -> Self
pub fn max_gas_amount(self, amount: u64) -> Self
Sets the maximum gas amount for all transactions.
Sourcepub fn expiration_secs(self, secs: u64) -> Self
pub fn expiration_secs(self, secs: u64) -> Self
Sets the expiration time in seconds from now.
Sourcepub fn add_payload(self, payload: TransactionPayload) -> Self
pub fn add_payload(self, payload: TransactionPayload) -> Self
Adds a transaction payload to the batch.
Sourcepub fn add_payloads(
self,
payloads: impl IntoIterator<Item = TransactionPayload>,
) -> Self
pub fn add_payloads( self, payloads: impl IntoIterator<Item = TransactionPayload>, ) -> Self
Adds multiple transaction payloads to the batch.
Sourcepub fn build(self) -> AptosResult<Vec<RawTransaction>>
pub fn build(self) -> AptosResult<Vec<RawTransaction>>
Builds raw transactions without signing.
§Errors
Returns an error if sender, starting_sequence_number, or chain_id is not set, or if building any transaction fails.
Sourcepub fn build_and_sign<A: Account>(
self,
account: &A,
) -> AptosResult<SignedTransactionBatch>
pub fn build_and_sign<A: Account>( self, account: &A, ) -> AptosResult<SignedTransactionBatch>
Builds and signs all transactions in the batch.
§Errors
Returns an error if building the transactions fails or if signing any transaction fails.
Trait Implementations§
Source§impl Clone for TransactionBatchBuilder
impl Clone for TransactionBatchBuilder
Source§fn clone(&self) -> TransactionBatchBuilder
fn clone(&self) -> TransactionBatchBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TransactionBatchBuilder
impl Debug for TransactionBatchBuilder
Auto Trait Implementations§
impl Freeze for TransactionBatchBuilder
impl RefUnwindSafe for TransactionBatchBuilder
impl Send for TransactionBatchBuilder
impl Sync for TransactionBatchBuilder
impl Unpin for TransactionBatchBuilder
impl UnsafeUnpin for TransactionBatchBuilder
impl UnwindSafe for TransactionBatchBuilder
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
Mutably borrows from an owned value. Read more