Add dependencies
Theweb3-solana library provides the abstraction classes like Transaction and AccountMeta to simplify building Solana transactions.
Example: Memo Program Transaction
In the following example, we are creating aTransaction that invokes the Memo Program to publish the message “Hello Solana” on-chain.
Create an instruction
A transaction instruction is comprised of a program id, a list of accounts, and instruction data specific to the program. To create an instruction, define a list ofAccountMeta that represent the accounts required by the instruction.
Then pass the encoded message as data into the TransactionInstruction constructor.
Create the Memo transaction
After creating the instructions, useMessage.Builder() to assemble the instructions and a blockhash to construct the a Transaction message. Then
pass the transaction message into the Transaction constructor.
See the previous Making RPC Requests guide for an example of how to fetch a blockhash.
