Class 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(SolanaAddress, List, String) 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.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic SolanaMessagecompile(SolanaAddress payer, List<Instruction> instructions, String recentBlockhash) A legacy message.static SolanaMessagecompileV0(SolanaAddress payer, List<Instruction> instructions, String recentBlockhash) A v0 message with no address lookup tables.The accounts named directly in the message; signers come first.The fee payer, the first account.The instructions with their accounts resolved.intHow many signatures the transaction carries; the first this many accounts sign.The Base58 recent blockhash.intLEGACYor 0.booleanWhether the message loads accounts through address lookup tables.booleanisSigner(int index) Whether the account at an index signs.booleanisWritable(int index) Whether the message marks the account at an index writable.static SolanaMessageparse(byte[] data) Reads a message, legacy or v0.byte[]The wire form, the bytes every signer signs.
-
Field Details
-
LEGACY
public static final int LEGACYThe version of a legacy message.- See Also:
-
-
Method Details
-
compile
public static SolanaMessage compile(SolanaAddress payer, List<Instruction> instructions, String recentBlockhash) A legacy message.
Parameters
payer: the fee payer, which signsinstructions: the instructions, run in orderrecentBlockhash: a Base58 blockhash fromgetLatestBlockhash, or a durable nonce
-
compileV0
public static SolanaMessage compileV0(SolanaAddress payer, List<Instruction> instructions, String recentBlockhash) A v0 message with no address lookup tables. -
serialize
public byte[] serialize()The wire form, the bytes every signer signs. -
parse
Reads a message, legacy or v0.
Throws
IllegalArgumentException: for malformed data or an unknown version
-
getVersion
public int getVersion()LEGACYor 0. -
getAccountKeys
The accounts named directly in the message; signers come first. -
getFeePayer
The fee payer, the first account. -
getRecentBlockhash
The Base58 recent blockhash. -
getNumRequiredSignatures
public int getNumRequiredSignatures()How many signatures the transaction carries; the first this many accounts sign. -
isSigner
public boolean isSigner(int index) Whether the account at an index signs. -
isWritable
public boolean isWritable(int index) Whether the message marks the account at an index writable. -
hasAddressLookups
public boolean hasAddressLookups()Whether the message loads accounts through address lookup tables. -
getInstructions
The instructions with their accounts resolved.
Throws
IllegalStateException: when an instruction names an account from a lookup table
-