Struct solana_sdk::transaction::Transaction
source · pub struct Transaction {
pub signatures: Vec<Signature>,
pub account_keys: Vec<Pubkey>,
pub last_id: Hash,
pub fee: u64,
pub program_ids: Vec<Pubkey>,
pub instructions: Vec<Instruction>,
}
Expand description
An atomic transaction
Fields
signatures: Vec<Signature>
A set of digital signature of account_keys
, program_ids
, last_id
, fee
and instructions
, signed by the first
signatures.len() keys of account_keys
account_keys: Vec<Pubkey>
The Pubkeys
that are executing this transaction userdata. The meaning of each key is
program-specific.
- account_keys[0] - Typically this is the
caller
public key.signature
is verified with account_keys[0]. In the future which key pays the fee and which keys have signatures would be configurable. - account_keys[1] - Typically this is the program context or the recipient of the tokens
last_id: Hash
The ID of a recent ledger entry.
fee: u64
The number of tokens paid for processing and storage of this transaction.
program_ids: Vec<Pubkey>
Keys identifying programs in the instructions vector.
instructions: Vec<Instruction>
Programs that will be executed in sequence and commited in one atomic transaction if all succeed.
Implementations
sourceimpl Transaction
impl Transaction
pub fn new<T: Serialize>(
from_keypair: &Keypair,
transaction_keys: &[Pubkey],
program_id: Pubkey,
userdata: &T,
last_id: Hash,
fee: u64
) -> Self
sourcepub fn new_with_instructions(
from_keypairs: &[&Keypair],
keys: &[Pubkey],
last_id: Hash,
fee: u64,
program_ids: Vec<Pubkey>,
instructions: Vec<Instruction>
) -> Self
pub fn new_with_instructions(
from_keypairs: &[&Keypair],
keys: &[Pubkey],
last_id: Hash,
fee: u64,
program_ids: Vec<Pubkey>,
instructions: Vec<Instruction>
) -> Self
Create a signed transaction
from_keypair
- The key used to sign the transaction. This key is stored as keys[0]account_keys
- The keys for the transaction. These are the program state instances or token recipient keys.last_id
- The PoH hash.fee
- The transaction fee.program_ids
- The keys that identify programs used in theinstruction
vector.instructions
- The programs and their arguments that the transaction will execute atomically
pub fn userdata(&self, instruction_index: usize) -> &[u8] ⓘ
pub fn key(
&self,
instruction_index: usize,
accounts_index: usize
) -> Option<&Pubkey>
pub fn signer_key(
&self,
instruction_index: usize,
accounts_index: usize
) -> Option<&Pubkey>
pub fn program_id(&self, instruction_index: usize) -> &Pubkey
sourcepub fn get_sign_data(&self) -> Vec<u8>
pub fn get_sign_data(&self) -> Vec<u8>
Get the transaction data to sign.
sourcepub fn verify_signature(&self) -> bool
pub fn verify_signature(&self) -> bool
Verify only the transaction signature.
sourcepub fn verify_refs(&self) -> bool
pub fn verify_refs(&self) -> bool
Verify that references in the instructions are valid
pub fn from(&self) -> &Pubkey
pub fn hash(transactions: &[Transaction]) -> Hash
Trait Implementations
sourceimpl BudgetTransaction for Transaction
impl BudgetTransaction for Transaction
sourcefn budget_new_taxed(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
fee: u64,
last_id: Hash
) -> Self
fn budget_new_taxed(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
fee: u64,
last_id: Hash
) -> Self
Create and sign a new Transaction. Used for unit-testing.
sourcefn budget_new(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
last_id: Hash
) -> Self
fn budget_new(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
last_id: Hash
) -> Self
Create and sign a new Transaction. Used for unit-testing.
sourcefn budget_new_timestamp(
from_keypair: &Keypair,
contract: Pubkey,
to: Pubkey,
dt: DateTime<Utc>,
last_id: Hash
) -> Self
fn budget_new_timestamp(
from_keypair: &Keypair,
contract: Pubkey,
to: Pubkey,
dt: DateTime<Utc>,
last_id: Hash
) -> Self
Create and sign a new Witness Timestamp. Used for unit-testing.
sourcefn budget_new_signature(
from_keypair: &Keypair,
contract: Pubkey,
to: Pubkey,
last_id: Hash
) -> Self
fn budget_new_signature(
from_keypair: &Keypair,
contract: Pubkey,
to: Pubkey,
last_id: Hash
) -> Self
Create and sign a new Witness Signature. Used for unit-testing.
sourcefn budget_new_on_date(
from_keypair: &Keypair,
to: Pubkey,
contract: Pubkey,
dt: DateTime<Utc>,
dt_pubkey: Pubkey,
cancelable: Option<Pubkey>,
tokens: u64,
last_id: Hash
) -> Self
fn budget_new_on_date(
from_keypair: &Keypair,
to: Pubkey,
contract: Pubkey,
dt: DateTime<Utc>,
dt_pubkey: Pubkey,
cancelable: Option<Pubkey>,
tokens: u64,
last_id: Hash
) -> Self
Create and sign a postdated Transaction. Used for unit-testing.
sourcefn budget_new_when_signed(
from_keypair: &Keypair,
to: Pubkey,
contract: Pubkey,
witness: Pubkey,
cancelable: Option<Pubkey>,
tokens: u64,
last_id: Hash
) -> Self
fn budget_new_when_signed(
from_keypair: &Keypair,
to: Pubkey,
contract: Pubkey,
witness: Pubkey,
cancelable: Option<Pubkey>,
tokens: u64,
last_id: Hash
) -> Self
Create and sign a multisig Transaction.
sourcefn verify_plan(&self) -> bool
fn verify_plan(&self) -> bool
Verify only the payment plan.
fn instruction(&self, instruction_index: usize) -> Option<Instruction>
fn system_instruction(
&self,
instruction_index: usize
) -> Option<SystemInstruction>
sourceimpl Clone for Transaction
impl Clone for Transaction
sourcefn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for Transaction
impl Debug for Transaction
sourceimpl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl LoaderTransaction for Transaction
impl LoaderTransaction for Transaction
sourceimpl PartialEq<Transaction> for Transaction
impl PartialEq<Transaction> for Transaction
sourcefn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
sourceimpl Serialize for Transaction
impl Serialize for Transaction
sourceimpl StorageTransaction for Transaction
impl StorageTransaction for Transaction
sourceimpl SystemTransaction for Transaction
impl SystemTransaction for Transaction
sourcefn system_create(
from_keypair: &Keypair,
to: Pubkey,
last_id: Hash,
tokens: u64,
space: u64,
program_id: Pubkey,
fee: u64
) -> Self
fn system_create(
from_keypair: &Keypair,
to: Pubkey,
last_id: Hash,
tokens: u64,
space: u64,
program_id: Pubkey,
fee: u64
) -> Self
Create and sign new SystemInstruction::CreateAccount transaction
sourcefn system_assign(
from_keypair: &Keypair,
last_id: Hash,
program_id: Pubkey,
fee: u64
) -> Self
fn system_assign(
from_keypair: &Keypair,
last_id: Hash,
program_id: Pubkey,
fee: u64
) -> Self
Create and sign new SystemInstruction::Assign transaction
sourcefn system_new(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
last_id: Hash
) -> Self
fn system_new(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
last_id: Hash
) -> Self
Create and sign new SystemInstruction::CreateAccount transaction with some defaults
sourcefn system_move(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
last_id: Hash,
fee: u64
) -> Self
fn system_move(
from_keypair: &Keypair,
to: Pubkey,
tokens: u64,
last_id: Hash,
fee: u64
) -> Self
Create and sign new SystemInstruction::Move transaction
sourcefn system_move_many(
from: &Keypair,
moves: &[(Pubkey, u64)],
last_id: Hash,
fee: u64
) -> Self
fn system_move_many(
from: &Keypair,
moves: &[(Pubkey, u64)],
last_id: Hash,
fee: u64
) -> Self
Create and sign new SystemInstruction::Move transaction to many destinations
sourcefn system_spawn(from_keypair: &Keypair, last_id: Hash, fee: u64) -> Self
fn system_spawn(from_keypair: &Keypair, last_id: Hash, fee: u64) -> Self
Create and sign new SystemInstruction::Spawn transaction