Struct TransactionBuilder
pub struct TransactionBuilder { /* private fields */ }Expand description
Builder for constructing Transaction instances.
This builder provides methods for creating transactions either by:
- Providing a pre-signed payload and signature
- Providing a payload and using
sign_and_build()to sign automatically
§Examples
§Sign and build in one step
use types::api::{Transaction, TransactionPayload};
let payload = TransactionPayload::builder()
.nonce(1)
.chain_id("real-1")
.build()
.expect("Failed to build");
let tx = Transaction::builder()
.payload(payload)
.sign_and_build("iotaprivkey1qrsd...")
.expect("Failed to sign");§Build with existing signature
use types::api::Transaction;
let tx = Transaction::builder()
.payload_base64("eyJzZW5kZXIi...")
.signature_base64("0x1a2b3c...")
.build()
.expect("Failed to build");Implementations§
§impl TransactionBuilder
impl TransactionBuilder
pub fn new() -> TransactionBuilder
pub fn new() -> TransactionBuilder
Creates a new TransactionBuilder with all fields initially unset.
pub fn client_request_id<S>(self, client_request_id: S) -> TransactionBuilder
pub fn client_request_id<S>(self, client_request_id: S) -> TransactionBuilder
Sets an optional client request identifier for tracking purposes.
This identifier can be used to track the transaction through the system and correlate requests with responses.
§Arguments
client_request_id- Any value that can be converted to a String (e.g., UUID)
§Examples
use types::api::Transaction;
let builder = Transaction::builder()
.client_request_id("393e6d50-7cf7-4069-a758-0e837e7178bc");pub fn signer<S>(self, signer: S) -> TransactionBuilder
pub fn signer<S>(self, signer: S) -> TransactionBuilder
Sets the envelope signer for v2 transactions.
v1 envelopes ignore this field. v2 envelopes require it: it is the
wallet address that actually signed this envelope, which may differ
from payload.owner when owner is a multisig address.
If left unset, sign_and_build will populate it automatically with
the signing key’s address when version is Some(2).
pub fn version(self, version: u8) -> TransactionBuilder
pub fn version(self, version: u8) -> TransactionBuilder
Sets an optional protocol version number.
§Arguments
version- The protocol version number (e.g., 1)
pub fn payload_base64<S>(self, payload: S) -> TransactionBuilder
pub fn payload_base64<S>(self, payload: S) -> TransactionBuilder
Sets the transaction payload as a base64-encoded string.
Use this method when you have a pre-encoded payload string.
§Arguments
payload- Base64-encoded JSON representation of TransactionPayload
§Examples
use types::api::Transaction;
let builder = Transaction::builder()
.payload_base64("eyJzZW5kZXIi...");pub fn signature_base64<S>(self, signature: S) -> TransactionBuilder
pub fn signature_base64<S>(self, signature: S) -> TransactionBuilder
pub fn payload(self, payload: TransactionPayload) -> TransactionBuilder
pub fn payload(self, payload: TransactionPayload) -> TransactionBuilder
Sets the transaction payload from a TransactionPayload instance.
Use this method when building a transaction from a structured payload
that will be signed using sign_and_build().
§Arguments
payload- A TransactionPayload instance
§Examples
use types::api::{Transaction, TransactionPayload};
let payload = TransactionPayload::builder()
.nonce(1)
.chain_id("real-1")
.build()
.expect("Failed to build");
let builder = Transaction::builder()
.payload(payload);pub fn sign_and_build<S>(
self,
signer: S,
) -> Result<Transaction, TransactionBuilderError>
pub fn sign_and_build<S>( self, signer: S, ) -> Result<Transaction, TransactionBuilderError>
Signs the transaction payload and builds a complete Transaction.
This method takes a signer (private key), encodes the payload, signs it, and constructs a complete transaction ready for submission.
§Arguments
signer- Any value that can be converted into a Signer (e.g., private key string)
§Returns
Ok(Transaction)- Successfully signed and built transactionErr(TransactionBuilderError)- Missing payload
§Behavior
- If the payload’s sender field is empty, it will be automatically set from the signer’s address
- The payload is serialized to JSON and base64-encoded
- The base64 payload is signed using Ed25519
- A complete Transaction is constructed with the encoded payload and signature
§Examples
use types::api::{Transaction, TransactionPayload};
let payload = TransactionPayload::builder()
.nonce(1)
.chain_id("real-1")
.build()
.expect("Failed to build");
let tx = Transaction::builder()
.client_request_id("393e6d50-7cf7-4069-a758-0e837e7178bc")
.payload(payload)
.sign_and_build("iotaprivkey1qrsd2u9ztqr6z2y78sp2ch8kcyak9cx3ezphkpp4acqaqruajxr6qye2645")
.expect("Failed to sign");pub fn build(self) -> Result<Transaction, TransactionBuilderError>
pub fn build(self) -> Result<Transaction, TransactionBuilderError>
Builds the Transaction from the configured builder.
Use this method when you have a pre-signed transaction with base64-encoded payload and signature strings.
§Returns
Ok(Transaction)- Successfully built transactionErr(TransactionBuilderError)- Missing required field(s)
§Errors
Returns TransactionBuilderError::MissingField if:
payload(base64 string) has not been setsignature(base64 string) has not been set
§Examples
use types::api::Transaction;
let tx = Transaction::builder()
.client_request_id("393e6d50-7cf7-4069-a758-0e837e7178bc")
.payload_base64("eyJzZW5kZXIi...")
.signature_base64("0x1a2b3c...")
.build()
.expect("Failed to build");Trait Implementations§
§impl Debug for TransactionBuilder
impl Debug for TransactionBuilder
§impl Default for TransactionBuilder
impl Default for TransactionBuilder
§fn default() -> TransactionBuilder
fn default() -> TransactionBuilder
Auto Trait Implementations§
impl Freeze for TransactionBuilder
impl RefUnwindSafe for TransactionBuilder
impl Send for TransactionBuilder
impl Sync for TransactionBuilder
impl Unpin for TransactionBuilder
impl UnsafeUnpin for TransactionBuilder
impl UnwindSafe for TransactionBuilder
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> InitializableFromZeroed for Twhere
T: Default,
impl<T> InitializableFromZeroed for Twhere
T: Default,
§unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.