Expand description
Transaction building API for the Sui blockchain.
This crate provides TransactionBuilder, for constructing user transactions or PTBs
(programmable transaction blocks). Inputs and commands are added incrementally, and the builder
resolves them into a finalized Transaction.
§Feature flags
intents(enabled by default): Enables high-level transaction intents (e.g.,CoinWithBalance) and the asyncTransactionBuilder::buildmethod that resolves intents and gas via an RPC client.
§Example
Build a simple SUI transfer transaction offline using TransactionBuilder::try_build:
use sui_sdk_types::Address;
use sui_sdk_types::Digest;
use sui_transaction_builder::ObjectInput;
use sui_transaction_builder::TransactionBuilder;
let mut tx = TransactionBuilder::new();
// Split 1 SUI from the gas coin
let amount = tx.pure(&1_000_000_000u64);
let gas = tx.gas();
let coins = tx.split_coins(gas, vec![amount]);
// Transfer to recipient
let recipient = tx.pure(&Address::ZERO);
tx.transfer_objects(coins, recipient);
// Set required metadata
tx.set_sender(Address::ZERO);
tx.set_gas_budget(500_000_000);
tx.set_gas_price(1000);
tx.add_gas_objects([ObjectInput::owned(Address::ZERO, 1, Digest::ZERO)]);
let transaction = tx.try_build().expect("build should succeed");Modules§
- intent
intents - High-level transaction intents.
Structs§
- Argument
- A opaque handle to a transaction input or command result.
- Function
- A structured representation of a Move function (
package::module::function), optionally with type arguments. - Object
Input - Description of an on-chain object to use as a transaction input.
- Simulation
Failure intents - Rich error information from a failed transaction simulation.
- Transaction
Builder - A builder for creating programmable transaction blocks.
Enums§
- Error
- Errors that can occur when building or resolving a transaction.