Struct Message

Source
pub struct Message {
    pub header: MessageHeader,
    pub account_keys: Vec<Pubkey>,
    pub recent_blockhash: Hash,
    pub instructions: Vec<CompiledInstruction>,
    pub address_table_lookups: Vec<MessageAddressTableLookup>,
}
Expand description

A Solana transaction message (v0).

This message format supports succinct account loading with on-chain address lookup tables.

See the message module documentation for further description.

Fieldsยง

ยงheader: MessageHeader

The message header, identifying signed and read-only account_keys. Header values only describe static account_keys, they do not describe any additional account keys loaded via address table lookups.

ยงaccount_keys: Vec<Pubkey>

List of accounts loaded by this transaction.

ยงrecent_blockhash: Hash

The blockhash of a recent block.

ยงinstructions: Vec<CompiledInstruction>

Instructions that invoke a designated program, are executed in sequence, and committed in one atomic transaction if all succeed.

ยงNotes

Program indexes must index into the list of message account_keys because program idโ€™s cannot be dynamically loaded from a lookup table.

Account indexes must index into the list of addresses constructed from the concatenation of three key lists:

  1. message account_keys
  2. ordered list of keys loaded from writable lookup table indexes
  3. ordered list of keys loaded from readable lookup table indexes
ยงaddress_table_lookups: Vec<MessageAddressTableLookup>

List of address table lookups used to load additional accounts for this transaction.

Implementationsยง

Sourceยง

impl Message

Source

pub fn sanitize(&self) -> Result<(), SanitizeError>

Sanitize message fields and compiled instruction indexes

Sourceยง

impl Message

Source

pub fn try_compile( payer: &Pubkey, instructions: &[Instruction], address_lookup_table_accounts: &[AddressLookupTableAccount], recent_blockhash: Hash, ) -> Result<Message, CompileError>

Create a signable transaction message from a payer public key, recent_blockhash, list of instructions, and a list of address_lookup_table_accounts.

ยงExamples

This example uses the solana_rpc_client, solana_sdk, and anyhow crates.

use anyhow::Result;
use solana_rpc_client::rpc_client::RpcClient;
use solana_program::address_lookup_table::{self, state::{AddressLookupTable, LookupTableMeta}};
use solana_sdk::{
     address_lookup_table_account::AddressLookupTableAccount,
     instruction::{AccountMeta, Instruction},
     message::{VersionedMessage, v0},
     pubkey::Pubkey,
     signature::{Keypair, Signer},
     transaction::VersionedTransaction,
};

fn create_tx_with_address_table_lookup(
    client: &RpcClient,
    instruction: Instruction,
    address_lookup_table_key: Pubkey,
    payer: &Keypair,
) -> Result<VersionedTransaction> {
    let raw_account = client.get_account(&address_lookup_table_key)?;
    let address_lookup_table = AddressLookupTable::deserialize(&raw_account.data)?;
    let address_lookup_table_account = AddressLookupTableAccount {
        key: address_lookup_table_key,
        addresses: address_lookup_table.addresses.to_vec(),
    };

    let blockhash = client.get_latest_blockhash()?;
    let tx = VersionedTransaction::try_new(
        VersionedMessage::V0(v0::Message::try_compile(
            &payer.pubkey(),
            &[instruction],
            &[address_lookup_table_account],
            blockhash,
        )?),
        &[payer],
    )?;

    Ok(tx)
}
Source

pub fn serialize(&self) -> Vec<u8> โ“˜

Serialize this message with a version #0 prefix using bincode encoding.

Source

pub fn is_key_called_as_program(&self, key_index: usize) -> bool

Returns true if the account at the specified index is called as a program by an instruction

Source

pub fn is_maybe_writable(&self, key_index: usize) -> bool

Returns true if the account at the specified index was requested as writable. Before loading addresses, we canโ€™t demote write locks for dynamically loaded addresses so this should not be used by the runtime.

Trait Implementationsยง

Sourceยง

impl AbiExample for Message

Sourceยง

impl Clone for Message

Sourceยง

fn clone(&self) -> Message

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 Message

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for Message

Sourceยง

fn default() -> Message

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl<'de> Deserialize<'de> for Message

Sourceยง

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

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

impl EncodableWithMeta for Message

Sourceยง

impl PartialEq for Message

Sourceยง

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl Serialize for Message

Sourceยง

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

Serialize this value into the given Serde serializer. Read more
Sourceยง

impl Eq for Message

Sourceยง

impl StructuralPartialEq for Message

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> AbiEnumVisitor for T
where T: Serialize + ?Sized,

Sourceยง

default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>

Sourceยง

impl<T> AbiEnumVisitor for T
where T: Serialize + AbiExample + ?Sized,

Sourceยง

default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>

Sourceยง

impl<T> AbiExample for T

Sourceยง

default fn example() -> T

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<CustErr, T, Request> FromReq<Cbor, Request, CustErr> for T
where Request: Req<CustErr> + Send + 'static, T: DeserializeOwned,

Sourceยง

async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
where Request: Req<CustErr> + Send + 'static, T: DeserializeOwned,

Sourceยง

async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
where Request: Req<CustErr> + Send + 'static, T: DeserializeOwned,

Sourceยง

async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
where Request: Req<CustErr> + Send + 'static, T: DeserializeOwned,

Sourceยง

async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<CustErr, T, Response> FromRes<Cbor, Response, CustErr> for T
where Response: ClientRes<CustErr> + Send, T: DeserializeOwned + Send,

Sourceยง

async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>

Attempts to deserialize the outputs from a response.
Sourceยง

impl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
where Response: ClientRes<CustErr> + Send, T: DeserializeOwned + Send,

Sourceยง

async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>

Attempts to deserialize the outputs from a response.
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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> IntoPropValue<Option<T>> for T

Sourceยง

fn into_prop_value(self) -> Option<T>

Convert self to a value of a Properties struct.
Sourceยง

impl<T> IntoPropValue<T> for T

Sourceยง

fn into_prop_value(self) -> T

Convert self to a value of a Properties struct.
Sourceยง

impl<CustErr, T, Request> IntoReq<Cbor, Request, CustErr> for T
where Request: ClientReq<CustErr>, T: Serialize + Send,

Sourceยง

fn into_req( self, path: &str, accepts: &str, ) -> Result<Request, ServerFnError<CustErr>>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<CustErr, T, Request> IntoReq<GetUrl, Request, CustErr> for T
where Request: ClientReq<CustErr>, T: Serialize + Send,

Sourceยง

fn into_req( self, path: &str, accepts: &str, ) -> Result<Request, ServerFnError<CustErr>>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<CustErr, T, Request> IntoReq<Json, Request, CustErr> for T
where Request: ClientReq<CustErr>, T: Serialize + Send,

Sourceยง

fn into_req( self, path: &str, accepts: &str, ) -> Result<Request, ServerFnError<CustErr>>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<CustErr, T, Request> IntoReq<PostUrl, Request, CustErr> for T
where Request: ClientReq<CustErr>, T: Serialize + Send,

Sourceยง

fn into_req( self, path: &str, accepts: &str, ) -> Result<Request, ServerFnError<CustErr>>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<CustErr, T, Response> IntoRes<Cbor, Response, CustErr> for T
where Response: Res<CustErr>, T: Serialize + Send,

Sourceยง

async fn into_res(self) -> Result<Response, ServerFnError<CustErr>>

Attempts to serialize the output into an HTTP response.
Sourceยง

impl<CustErr, T, Response> IntoRes<Json, Response, CustErr> for T
where Response: Res<CustErr>, T: Serialize + Send,

Sourceยง

async fn into_res(self) -> Result<Response, ServerFnError<CustErr>>

Attempts to serialize the output into an HTTP response.
Sourceยง

impl<T> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> Serializable for T

Sourceยง

fn ser(&self) -> Result<String, SerializationError>

Serializes the object to a string.
Sourceยง

fn de(json: &str) -> Result<T, SerializationError>

Deserializes the object from some bytes.
Sourceยง

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Sourceยง

fn super_from(input: T) -> O

Convert from a type to another type.
Sourceยง

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Sourceยง

fn super_into(self) -> O

Convert from a type to another type.
Sourceยง

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

Sourceยง

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
Sourceยง

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
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<Cfg> TryIntoConfig for Cfg

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
Sourceยง

impl<Token, Builder, How> AllPropsFor<Builder, How> for Token
where Builder: Buildable<Token>, <Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,

Sourceยง

impl<T> DependencyElement for T
where T: 'static + PartialEq + Clone,

Sourceยง

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Sourceยง

impl<El> ElementDescriptorBounds for El
where El: Debug,

Sourceยง

impl<T> ErasedDestructor for T
where T: 'static,

Sourceยง

impl<T> HasAllProps<(), T> for T