Skip to content

Instantly share code, notes, and snippets.

@AlmostEfficient
Created July 6, 2023 11:36
Simple native Solana Rust program that echoes back whatever message you send it.
use solana_program::{
account_info::{AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
pubkey::Pubkey,
};
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
instruction_data: &[u8]
) -> ProgramResult {
// Log the received data
msg!("Received data: {:?}", instruction_data);
// Echo back the instruction data
if let Ok(instruction_str) = std::str::from_utf8(instruction_data) {
msg!("Echo: {}", instruction_str);
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment