pub struct TransactionBatchBuilder { /* private fields */ }Expand description
Builder for creating a batch of transactions.
This builder handles:
- Automatic sequence number management (incrementing from a starting value)
- Transaction signing
Gas parameters use fixed defaults (a gas_unit_price of 100 octas and a
max_gas_amount of 2,000,000) unless overridden via
gas_unit_price / max_gas_amount.
This builder does not query the network for a recommended gas price;
live gas-price estimation happens one level up in BatchOperations::build,
which fetches the estimate and passes it to this builder.
§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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more