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:
  1. create a transaction
  1. create an instruction
  1. add the instruction to the transaction
  1. 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:

“Success is not final, failure is not fatal: it is the courage to continue that counts.“

Winston Churchill


© Hiếu Trần 2020 - 2025

Tip: Use console.table() for better array logging!
Anime Character