Skip to main content

VersionedTransaction

Enum VersionedTransaction 

Source
pub enum VersionedTransaction {
    Legacy {
        signatures: Vec<SignatureBytes>,
        message: LegacyMessage,
    },
    V0 {
        signatures: Vec<SignatureBytes>,
        message: VersionedMessageV0,
    },
}
Expand description

Versioned transaction format

Variants§

§

Legacy

Legacy transaction format (pre-versioned transactions)

Fields

§signatures: Vec<SignatureBytes>

List of signatures

§message: LegacyMessage

Message to sign

§

V0

Versioned transaction format V0

Fields

§signatures: Vec<SignatureBytes>

List of signatures

§message: VersionedMessageV0

Message to sign

Implementations§

Source§

impl VersionedTransaction

Source

pub fn new(message: VersionedMessage) -> Self

Create a new versioned transaction

Source

pub fn add_signature(&mut self, signature: SignatureBytes)

Add a signature to the transaction

Source

pub fn num_required_signatures(&self) -> u8

Get the number of required signatures

Source

pub fn num_readonly_signed_accounts(&self) -> u8

Get the number of read-only signed accounts

Source

pub fn num_readonly_unsigned_accounts(&self) -> u8

Get the number of read-only unsigned accounts

Source

pub fn account_keys(&self) -> &[Pubkey]

Get the account keys

Source

pub fn recent_blockhash(&self) -> &[u8; 32]

Get the recent blockhash

Source

pub fn instructions(&self) -> &[CompiledInstruction]

Get the instructions

Source

pub fn signatures(&self) -> &[SignatureBytes]

Source

pub fn signatures_mut(&mut self) -> &mut Vec<SignatureBytes>

Source

pub fn instructions_mut(&mut self) -> &mut Vec<CompiledInstruction>

Source

pub fn get_compute_unit_price(&self) -> Option<u64>

Source

pub fn set_compute_unit_price(&mut self, micro_lamports: u64) -> Result<bool>

Source

pub fn get_compute_unit_limit(&self) -> Option<u32>

Source

pub fn set_compute_unit_limit(&mut self, units: u32) -> Result<bool>

Source

pub fn add_instruction(&mut self, instruction: Instruction) -> Result<()>

Source

pub fn serialize_message(&self) -> Result<Vec<u8>>

Source

pub fn serialize(&self) -> Result<Vec<u8>>

Source

pub fn deserialize_with_version(bytes: &[u8]) -> Result<Self>

Deserialize a versioned transaction from bytes

Examples found in repository?
examples/decode_tx.rs (line 16)
4fn main()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MtWHz2EUnYgJSxOMI1cDcABoNbXAMFAQ==";
7
8    // Decode base64 transaction
9    let tx_bytes = base64::engine::general_purpose::STANDARD.decode(tx)?;
10
11    // Print the transaction bytes structure
12    println!("Transaction bytes length: {}", tx_bytes.len());
13    println!("First byte (signature count): 0x{:02x}", tx_bytes[0]);
14
15    // Try to decode as versioned transaction using manual deserialization
16    match VersionedTransaction::deserialize_with_version(&tx_bytes) {
17        Ok(decoded_tx) => {
18            println!("✅ Successfully decoded transaction from wire format");
19            print_versioned_transaction(&decoded_tx);
20        }
21        Err(e) => {
22            println!("❌ Failed to decode transaction: {e}");
23        }
24    }
25
26    Ok(())
27}

Trait Implementations§

Source§

impl BorshDeserialize for VersionedTransaction

Source§

fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for VersionedTransaction

Source§

fn serialize<__W: Write>(&self, writer: &mut __W) -> Result<(), Error>

Source§

impl Clone for VersionedTransaction

Source§

fn clone(&self) -> VersionedTransaction

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for VersionedTransaction

Source§

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

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

impl<'de> Deserialize<'de> for VersionedTransaction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl EnumExt for VersionedTransaction

Source§

fn deserialize_variant<__R: Read>( reader: &mut __R, variant_tag: u8, ) -> Result<Self, Error>

Deserialises given variant of an enum from the reader. Read more
Source§

impl Serialize for VersionedTransaction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.