Skip to content

Instantly share code, notes, and snippets.

@AlmostEfficient
Created July 6, 2023 11:36
Show Gist options
  • Save AlmostEfficient/932ea71a2dfe04f4c35b4f6c4c32b3ad to your computer and use it in GitHub Desktop.
Save AlmostEfficient/932ea71a2dfe04f4c35b4f6c4c32b3ad to your computer and use it in GitHub Desktop.
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