pub struct Transaction {Show 17 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 chain_id: u16,
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§chain_id: u16§signature: Option<TnSignature>§fee_payer_state_proof: Option<StateProof>§fee_payer_account_meta_raw: Option<Vec<u8>>Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(fee_payer: TnPubkey, program: TnPubkey, fee: u64, nonce: u64) -> Self
pub fn new(fee_payer: TnPubkey, program: TnPubkey, fee: u64, nonce: u64) -> Self
Create a new unsigned transaction
Sourcepub fn new_raw_instruction(
fee_payer: &TnPubkey,
program: &TnPubkey,
instruction_data: &[u8],
) -> Result<Self, Box<dyn Error>>
pub fn new_raw_instruction( fee_payer: &TnPubkey, program: &TnPubkey, instruction_data: &[u8], ) -> Result<Self, Box<dyn Error>>
Create a minimal transaction with just a program ID and instruction data. Used for fake event transactions that don’t need accounts or fees.
pub fn has_fee_payer_state_proof(&self) -> bool
pub fn may_compress_account(&self) -> bool
pub fn get_signature(&self) -> Option<Signature>
pub fn with_may_compress_account(self) -> Self
Sourcepub fn with_fee_payer_state_proof(self, state_proof: &StateProof) -> Self
pub fn with_fee_payer_state_proof(self, state_proof: &StateProof) -> Self
Builder method: set fee payer state proof
Sourcepub fn with_fee_payer_account_meta_raw(self, account_meta_raw: Vec<u8>) -> Self
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
Sourcepub fn without_fee_payer_state_proof(self) -> Self
pub fn without_fee_payer_state_proof(self) -> Self
Builder method: remove fee payer state proof
Sourcepub fn with_rw_accounts(self, accounts: Vec<TnPubkey>) -> Self
pub fn with_rw_accounts(self, accounts: Vec<TnPubkey>) -> Self
Builder method: add read-write accounts
Sourcepub fn with_r_accounts(self, accounts: Vec<TnPubkey>) -> Self
pub fn with_r_accounts(self, accounts: Vec<TnPubkey>) -> Self
Builder method: add read-only accounts
Sourcepub fn add_rw_account(self, account: TnPubkey) -> Self
pub fn add_rw_account(self, account: TnPubkey) -> Self
Builder method: add a single read-write account
Sourcepub fn add_r_account(self, account: TnPubkey) -> Self
pub fn add_r_account(self, account: TnPubkey) -> Self
Builder method: add a single read-only account
Sourcepub fn with_instructions(self, instructions: Vec<u8>) -> Self
pub fn with_instructions(self, instructions: Vec<u8>) -> Self
Builder method: add instruction data
Sourcepub fn with_compute_units(self, units: u32) -> Self
pub fn with_compute_units(self, units: u32) -> Self
Builder method: set compute units
Sourcepub fn with_state_units(self, units: u16) -> Self
pub fn with_state_units(self, units: u16) -> Self
Builder method: set state units
Sourcepub fn with_memory_units(self, units: u16) -> Self
pub fn with_memory_units(self, units: u16) -> Self
Builder method: set memory units
Sourcepub fn with_expiry_after(self, expiry: u32) -> Self
pub fn with_expiry_after(self, expiry: u32) -> Self
Builder method: set expiry
Sourcepub fn with_nonce(self, nonce: u64) -> Self
pub fn with_nonce(self, nonce: u64) -> Self
Builder method: set nonce
Sourcepub fn with_start_slot(self, slot: u64) -> Self
pub fn with_start_slot(self, slot: u64) -> Self
Builder method: set start slot
Sourcepub fn with_chain_id(self, chain_id: u16) -> Self
pub fn with_chain_id(self, chain_id: u16) -> Self
Builder method: set chain ID
Sourcepub fn sign(&mut self, private_key: &[u8; 32]) -> Result<(), Box<dyn Error>>
pub fn sign(&mut self, private_key: &[u8; 32]) -> Result<(), Box<dyn Error>>
Sign the transaction with a 32-byte Ed25519 private key
Sourcepub fn to_wire(&self) -> Vec<u8> ⓘ
pub fn to_wire(&self) -> Vec<u8> ⓘ
Serialize to on-wire format (WireTxnHdrV1) Wire format: header + accounts + instr_data + state_proof + account_meta + signature
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more