I have Program A. It makes a CPI call to Program B via invoke_signed.

User makes a call to the Program A. These accounts will be passed to the Program B:

  • token_program: AccountInfo<'a>
  • source: AccountInfo<'a>
  • destination: AccountInfo<'a>
  • authority: AccountInfo<'a>

Then, I want Program B to make another CPI call to Program C. On behalf and using seeds of the Program A

So, the problem is - how do I pass the Program C account_info? The first thought was - can I hardcode it? like:

let program_c = Pubkey::from_str("PubKEyHere111111...") 

But... I'm not allowed to 'hardcode' it in Program B. There is no way to convert PubKey to account_info. Because that's how the Solana Runtime works - you should pass all the Account_Metas beforehand. But, is it still a way to do that except passing it explicitly to the Program A?


1 Answer 1


The accounts needed for Program C needs to be passed in via the CPI call made to Program B. Which circles back to the accounts needed for both Program B and Program C needs to be passed in when the user makes a call to Program A

There is no other way to do this.

  • 1
    Thank you for the answer. Here is what I have found if someone is interested: ...Because the only way for a program to acquire AccountInfo values is by receiving them from the runtime at the program entrypoint, any account required by the callee program must transitively be required by the caller program, and provided by its caller... docs.rs/solana-program/latest/solana_program/…
    – Michael
    Aug 16 at 14:25
  • That's a great description! It's worth putting that as an answer
    – C.OG
    Aug 16 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.