I am writing a program of which I cannot know the program ID ahead of time for several non-trivial reasons.

I am curious whether or not it is safe to assume the safety of the program_id passed via the entry-point.

my deep dive so far indicates it is safe, but I just want some external feedback before continuing with what could maybe prove to be a detrimentally false assumption.

1 Answer 1


If you look at the definition of the program entrypoint at https://docs.solana.com/developing/on-chain-programs/developing-rust#program-entrypoint, you'll see:

This entrypoint takes a generic byte array which contains the serialized program parameters (program id, accounts, instruction data, etc...)

And you'll get the full spec at https://docs.solana.com/developing/on-chain-programs/overview#input-parameter-serialization, which includes the program's pubkey at the end.

If this is ever broken, the network will have huge issues!

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.