date
Jul 9, 2024
slug
using-custom-onchain-programs
status
Published
tags
NodeJs
Solana
summary
Solana has multiple onchain programs you can use. Instructions that use these programs need to have data in a custom format determined by the program.
type
Post
Basic scaffolding
We'll start by using the same packages and .env file we made earlier in Intro to Writing Data.
Name the file send-ping-transaction.ts:
Ping program
Now let's talk to the Ping program! To do this, we need to:
- create a transaction
- create an instruction
- add the instruction to the transaction
- send the transaction
Remember, the most challenging piece here is including the right information in the instructions. We know the address of the program that we are calling. We also know that the program writes data to a separate account whose address we also have. Let’s add the string versions of both of those as constants at the top of the file: