Anatomy of a Solana Transaction
structures and properties.
- solana
- solana_operation
- solana_transaction
Transaction: {message: Message, signatures: Signature[]}
A transaction is the container of one ore more operations that are meant to be executed on the blockchain. Each transaction contains one or more instructions. A instruction references one program address, a list of accounts, and call data.
The transaction will have a message section as part of its structure. The message contains a list of instructions. The instructions will all be processed, or none will be processed. The other section of a transaction is the signature section, containing an array of signatures. The elements of a transaction message: header, account addresses, recent blockhash, instruction array. The signature array is simply a collection of all signatures by the required signer accounts.
Message: header, accountKeys, recentBlockhash, instructions
The message header specifies how many signer accounts are involved in the tx, how many non signer accounts, and how many signatures are required.
accountKeys field hosts a list of account addresses, sorted by privileges in the context of the transaction. The ordering is - signer read/write accounts, signer read only accounts, non signer read/write accounts, non signer read only accounts.
The recentBlockhash is a timestamp which enables to verify the transaction is not stale and helps prevent duplication. The maximum age of a transaction's blockhash is 150 blocks. This is around 1 minute at 400ms block time.
Instruction: {keys: AccountMeta[], programId: string, data: Byte[]}
Each operation is described by an instruction. An instruction is a program function which should be called with the passed function arguments. Each instruction references the accounts it reads from or writes to. The instruction also specifies the program address and the call data.
References