Courses

Building Your First Solana Program
Solana · Chapter 6

Building Your First Solana Program

Start with the Anchor template in Playground. Its initialize instruction is a useful first program: it accepts a request and completes without building a complicated app.

The basics

  • Find the initialize function inside the program module. Keep the generated program ID and account definitions.
  • Add the log line shown below inside that function, before its Ok(()) return. Build the program.
  • The log records a message when the instruction runs; it does not save a journal entry. Persistent data needs a data account.

Small example

// Inside the generated initialize function, before Ok(()):
msg!("Hello from my first Solana program!");

Try it yourself

Build your modified template. In the next lesson, deploy it to Devnet and call initialize to look for your message in the transaction logs.

Read more in the official documentation

@ Daniel Burlacu