While defining my accounts' structures I encountered this error:

a non-optional init constraint requires a non-optional system_program field to exist in the account validation struct. Use the Program type to add the system_program field to your validation struct.

Can someone explain to me that what is a system_program?

1 Answer 1


The system_program is the program that owns all normal wallet accounts and you also need it to create new accounts. So whenever you create a new account you need to call the system_program to allocate space for them.

When you use init for an anchor account this will internally also do a cpi (cross program invocation) to the system program to create that account. That is why you need to add it whenever you use init or init_if_needed.

On solana you always need to add all accounts that are touched by a transaction. This is so that solana can parallelize the execution

There is btw a limit of 10kb in size for accounts that are created like that. The maximum account size is 10mb though.


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.