Class SolanaMessage

java.lang.Object
com.codename1.crypto.solana.SolanaMessage

public final class SolanaMessage extends Object

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 Details

    • LEGACY

      public static final int LEGACY
      The 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 signs
      • instructions: the instructions, run in order
      • recentBlockhash: a Base58 blockhash from getLatestBlockhash, 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

      public static SolanaMessage parse(byte[] data)

      Reads a message, legacy or v0.

      Throws
      • IllegalArgumentException: for malformed data or an unknown version
    • getVersion

      public int getVersion()
      LEGACY or 0.
    • getAccountKeys

      public List<SolanaAddress> getAccountKeys()
      The accounts named directly in the message; signers come first.
    • getFeePayer

      public SolanaAddress getFeePayer()
      The fee payer, the first account.
    • getRecentBlockhash

      public String 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

      public List<Instruction> getInstructions()

      The instructions with their accounts resolved.

      Throws
      • IllegalStateException: when an instruction names an account from a lookup table