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: MessageHeaderThe 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: HashThe 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:
- message
account_keys - ordered list of keys loaded from
writablelookup table indexes - ordered list of keys loaded from
readablelookup table indexes
address_table_lookups: Vec<MessageAddressTableLookup>List of address table lookups used to load additional accounts for this transaction.
Implementationsยง
Sourceยงimpl Message
impl Message
Sourcepub fn sanitize(&self) -> Result<(), SanitizeError>
pub fn sanitize(&self) -> Result<(), SanitizeError>
Sanitize message fields and compiled instruction indexes
Sourceยงimpl Message
impl Message
Sourcepub fn try_compile(
payer: &Pubkey,
instructions: &[Instruction],
address_lookup_table_accounts: &[AddressLookupTableAccount],
recent_blockhash: Hash,
) -> Result<Message, CompileError>
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)
}Sourcepub fn serialize(&self) -> Vec<u8> โ
pub fn serialize(&self) -> Vec<u8> โ
Serialize this message with a version #0 prefix using bincode encoding.
Sourcepub fn is_key_called_as_program(&self, key_index: usize) -> bool
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
Sourcepub fn is_maybe_writable(&self, key_index: usize) -> bool
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<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Sourceยงfn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Sourceยงimpl EncodableWithMeta for Message
impl EncodableWithMeta for Message
type Encoded = UiMessage
fn encode_with_meta( &self, encoding: UiTransactionEncoding, meta: &TransactionStatusMeta, ) -> <Message as EncodableWithMeta>::Encoded
fn json_encode(&self) -> <Message as EncodableWithMeta>::Encoded
Sourceยงimpl Serialize for Message
impl Serialize for Message
Sourceยงfn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementationsยง
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementationsยง
Sourceยงimpl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Sourceยงimpl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<CustErr, T, Request> FromReq<Cbor, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<Cbor, Request, CustErr> for T
Sourceยงasync fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Sourceยงimpl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
Sourceยงasync fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Sourceยงimpl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
Sourceยงasync fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Sourceยงimpl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
Sourceยงasync fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Sourceยงimpl<CustErr, T, Response> FromRes<Cbor, Response, CustErr> for T
impl<CustErr, T, Response> FromRes<Cbor, Response, CustErr> for T
Sourceยงasync fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
Sourceยงimpl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
impl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
Sourceยงasync fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSourceยงimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Sourceยงfn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Sourceยงimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Sourceยงfn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.