pub struct Transaction;Expand description
Transaction related functionality.
This struct provides ability to interact with transactions.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub const fn construct(
signer_id: AccountId,
receiver_id: AccountId,
) -> ConstructTransaction
pub const fn construct( signer_id: AccountId, receiver_id: AccountId, ) -> ConstructTransaction
Constructs a new transaction builder with the given signer and receiver IDs. This pattern is useful for batching actions into a single transaction.
This is the low level interface for constructing transactions. It is designed to be used in scenarios where more control over the transaction process is required.
§Example
This example constructs a transaction with a two transfer actions.
use near_api::{*, types::{transaction::actions::{Action, TransferAction}, json::U128}};
let signer = Signer::new(Signer::from_ledger())?;
let transaction_result = Transaction::construct(
"sender.near".parse()?,
"receiver.near".parse()?
)
.add_action(Action::Transfer(
TransferAction {
deposit: NearToken::from_near(1),
},
))
.add_action(Action::Transfer(
TransferAction {
deposit: NearToken::from_near(1),
},
))
.with_signer(signer)
.send_to_mainnet()
.await?;Sourcepub fn use_transaction(
unsigned_tx: PrepopulateTransaction,
signer: Arc<Signer>,
) -> ExecuteSignedTransaction
pub fn use_transaction( unsigned_tx: PrepopulateTransaction, signer: Arc<Signer>, ) -> ExecuteSignedTransaction
Signs a transaction with the given signer.
This provides ability to sign custom constructed pre-populated transactions.
§Examples
use near_api::*;
let signer = Signer::new(Signer::from_ledger())?;
let transaction_result = Transaction::use_transaction(
unsigned_tx,
signer
)
.send_to_mainnet()
.await?;Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
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 moreAuto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
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