Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class SolanaMessage
- Object
- SolanaMessage
The part of a transaction that is signed: the accounts, a recent blockhash and the
compiled instructions. Both wire versions are read and written: the legacy format and v0.
compile orders accounts the way the Solana SDK does: the fee payer first, then the
writable signers, the read-only signers, the writable and the read-only non-signers, each
group in order of first appearance, with every program after the accounts named before it.
A v0 message read from the wire may name accounts through address lookup tables; those are kept as they are so the message re-serializes unchanged, but only its static keys can be resolved here.
Fields
public static final int LEGACY = -1 | The version of a legacy message. |
Methods
Inherited methods
Field details
LEGACY
public static final int LEGACY = -1Method details
compile
public static SolanaMessage compile(SolanaAddress payer, List<Instruction> instructions, String recentBlockhash)Parameters
payerSolanaAddress- the fee payer, which signs
instructionsList<Instruction>- the instructions, run in order
recentBlockhashString- a Base58 blockhash from
getLatestBlockhash, or a durable nonce
compileV0
public static SolanaMessage compileV0(SolanaAddress payer, List<Instruction> instructions, String recentBlockhash)serialize
public byte[] serialize()parse
public static SolanaMessage parse(byte[] data)Throws
IllegalArgumentException- for malformed data or an unknown version
getVersion
public int getVersion()LEGACY or 0.getAccountKeys
public List<SolanaAddress> getAccountKeys()getFeePayer
public SolanaAddress getFeePayer()getRecentBlockhash
public String getRecentBlockhash()getNumRequiredSignatures
public int getNumRequiredSignatures()isSigner
public boolean isSigner(int index)isWritable
public boolean isWritable(int index)hasAddressLookups
public boolean hasAddressLookups()getInstructions
public List<Instruction> getInstructions()Throws
IllegalStateException- when an instruction names an account from a lookup table