Back
+20 XP
4/16
Challenge: Add an Instruction
Time to modify the program. Add a greet instruction that logs a greeting message.
Requirements
- Add a new function
greetinside the#[program]module - It should take
_ctx: Context<Greet>as its parameter - It should call
msg!("Hello, Solana!")and returnOk(()) - Add a corresponding
Greetaccounts struct (can be empty, likeInitialize)
Tips
- Follow the same pattern as the existing
initializefunction - The accounts struct name must match the
Context<T>generic - Don't forget
#[derive(Accounts)]on your new struct
Test Cases
Program compiles successfully
Input:
Expected: trueCode contains a greet function
Input:
Expected: true