Send Data to Program 2

PHOTO EMBED

Tue Mar 14 2023 22:17:34 GMT+0000 (Coordinated Universal Time)

Saved by @luisjdominguezp ##rust

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{

    let (key, rem) = instruction_data.split_first().unwrap();
    
    let value: u64=rem
        .get(0..8)        
        .and_then(|slice|slice.try_into().ok())
        .map(u64::from_le_bytes)
        .unwrap_or(0);
    msg!("value {:?}:", value);
    msg!("El ingrediente secreto de mi sopa de ingrediente secreto es... nada");
    msg!("Program id: {}, accounts: {}, instructions: {:?}",
        program_id,
        accounts.len(),
        instruction_data
    );

    Ok(())
}
content_copyCOPY