Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7994

Passing PDA seeds and bump to sol_invoke_signed_c syscall in solana_nostd_entrypoint environment: missing required signature for instruction

$
0
0

Before: There seemed to be a lack of solana nostd entrypoint documentation, I couldn't find any good resources.

I made solana program using solana_nostd_entrypoint.I want to create PDA account using InstructionC.

        let rent = solana_program::rent::Rent::default();        let space = 1000;        let rent_lamports = rent.minimum_balance(space);        let mut instruction_data = [0u8; 56];        instruction_data[4..12].copy_from_slice(&rent_lamports.to_le_bytes());        instruction_data[12..20].copy_from_slice(&space.to_le_bytes());        instruction_data[20..52].copy_from_slice(program_id.as_ref());        let instruction_accounts = [signer.to_meta_c(), game_pda.to_meta_c()];        let instruction = InstructionC {            program_id: &system_program::ID,            accounts: instruction_accounts.as_ptr(),            accounts_len: instruction_accounts.len() as u64,            data: instruction_data.as_ptr(),            data_len: instruction_data.len() as u64,        };        let infos = [signer.to_info_c(), game_pda.to_info_c()];        let seeds: &[&[&[u8]]] = &[&[GAME_PDA, &[GAME_PDA_BUMP]]];        #[cfg(target_os = "solana")]        unsafe {            solana_program::syscalls::sol_invoke_signed_c(&instruction as *const InstructionC as *const u8,                infos.as_ptr() as *const u8,                infos.len() as u64,                seeds.as_ptr() as *const u8,                seeds.len() as u64,            );        }

But sol_invoke_signed_c fails because of lack of pda signature. Error log:

transactionLogs: ['Program ProgramID invoke [1]','Program 11111111111111111111111111111111 invoke [2]',"Allocate: 'to' account Address { address: PDA account here, base: None } must sign",'Program 11111111111111111111111111111111 failed: missing required signature for instruction','Program ProgramID  consumed 1555 of 200000 compute units','Program ProgramID  failed: missing required signature for instruction'  ]

Am I wrong to pass pda seeds and bump to sol_invoke_signed_c syscall cpi?

How can I fix this error?


Viewing all articles
Browse latest Browse all 7994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>