Transaction

Struct Transaction 

Source
pub struct Transaction {
Show 16 fields pub fee_payer: TnPubkey, pub program: TnPubkey, pub rw_accs: Option<Vec<TnPubkey>>, pub r_accs: Option<Vec<TnPubkey>>, pub instructions: Option<Vec<u8>>, pub fee: u64, pub req_compute_units: u32, pub req_state_units: u16, pub req_memory_units: u16, pub expiry_after: u32, pub start_slot: u64, pub nonce: u64, pub flags: u8, pub signature: Option<TnSignature>, pub fee_payer_state_proof: Option<StateProof>, pub fee_payer_account_meta_raw: Option<Vec<u8>>,
}
Expand description

Normal Rust struct for transaction construction

Fields§

§fee_payer: TnPubkey§program: TnPubkey§rw_accs: Option<Vec<TnPubkey>>§r_accs: Option<Vec<TnPubkey>>§instructions: Option<Vec<u8>>§fee: u64§req_compute_units: u32§req_state_units: u16§req_memory_units: u16§expiry_after: u32§start_slot: u64§nonce: u64§flags: u8§signature: Option<TnSignature>§fee_payer_state_proof: Option<StateProof>§fee_payer_account_meta_raw: Option<Vec<u8>>

Implementations§

Source§

impl Transaction

Source

pub fn new(fee_payer: TnPubkey, program: TnPubkey, fee: u64, nonce: u64) -> Self

Create a new unsigned transaction

Source

pub fn has_fee_payer_state_proof(&self) -> bool

Source

pub fn may_compress_account(&self) -> bool

Source

pub fn get_signature(&self) -> Option<Signature>

Source

pub fn with_may_compress_account(self) -> Self

Source

pub fn with_fee_payer_state_proof(self, state_proof: &StateProof) -> Self

Builder method: set fee payer state proof

Source

pub fn with_fee_payer_account_meta_raw(self, account_meta_raw: Vec<u8>) -> Self

Builder method: set fee payer account meta as raw bytes

Source

pub fn without_fee_payer_state_proof(self) -> Self

Builder method: remove fee payer state proof

Source

pub fn with_rw_accounts(self, accounts: Vec<TnPubkey>) -> Self

Builder method: add read-write accounts

Source

pub fn with_r_accounts(self, accounts: Vec<TnPubkey>) -> Self

Builder method: add read-only accounts

Source

pub fn add_rw_account(self, account: TnPubkey) -> Self

Builder method: add a single read-write account

Source

pub fn add_r_account(self, account: TnPubkey) -> Self

Builder method: add a single read-only account

Source

pub fn with_instructions(self, instructions: Vec<u8>) -> Self

Builder method: add instruction data

Source

pub fn with_compute_units(self, units: u32) -> Self

Builder method: set compute units

Source

pub fn with_state_units(self, units: u16) -> Self

Builder method: set state units

Source

pub fn with_memory_units(self, units: u16) -> Self

Builder method: set memory units

Source

pub fn with_expiry_after(self, expiry: u32) -> Self

Builder method: set expiry

Source

pub fn with_nonce(self, nonce: u64) -> Self

Builder method: set nonce

Source

pub fn with_start_slot(self, slot: u64) -> Self

Builder method: set start slot

Source

pub fn sign(&mut self, private_key: &[u8; 32]) -> Result<(), Box<dyn Error>>

Sign the transaction with a 32-byte Ed25519 private key

Source

pub fn verify(&self) -> bool

Verify the transaction signature

Source

pub fn to_wire(&self) -> Vec<u8>

Serialize to on-wire format (WireTxnHdrV1)

Source

pub fn from_wire(bytes: &[u8]) -> Option<Self>

Deserialize from on-wire format (WireTxnHdrV1)

Source

pub fn get_field_from_wire(bytes: &[u8], field: &str) -> Option<Vec<u8>>

Accessor: read a field from serialized bytes by name

Trait Implementations§

Source§

impl Clone for Transaction

Source§

fn clone(&self) -> Transaction

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Transaction

Source§

fn default() -> Transaction

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more