Created
July 6, 2023 11:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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