Beginner questions for you. I have a program that can successfully create and later modify a PDA account with some basic data. The Account struct is very basic:

pub struct CustomPdaAccount {
    pub value: u32,

I also have a completely separate on-chain program that simply takes in a regular account's data (one with its own keypair, not a PDA, but has the same account structure) and multiplies the current value by some random number. Nothing fancy at all.

That said, how would/should I proceed to make these two programs work together? Is this the territory of CPIs or something else? It would be neat to have my first on-chain program create and initializes a PDA account, and then my second on-chain program could be called to modify the data. However, my understanding is that PDA accounts can only be modified by the program that originally initialized/created the account.

Obviously, I could simply add the multiplication instruction logic inside the first program, rebuild, deploy, and then I'm left with a single program that does it all. Just curious if there is a Solana feature I should explore further.

1 Answer 1


If I understood you correctly, you want to do something like this:

There is a PDA state Account that is owned by Program A, that stores the state related to this Program. You want some functionality on Program B to modify this state account.

  1. User will pass Account to Program A
  2. Program A will pass it to Program B
  3. Program B will modify the state of the Account

To modify the state account, the Program must be an owner of this account. So, in this case, Program B MUST be an owner of the Account. This is the territory of CPI, and in your case, it is not possible. Simply put, if you are creating a PDA State Account owned by some Program, only this Program will be able to modify it's state

  • Yes, you summarized my hypothetical scenario correctly. It sounds like in this case I would need to use a regular state account (non-PDA account) and CPI to make this simple scenario work. Thanks for clarifying! Very helpful as I learn these fundamentals. Commented Aug 16, 2022 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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