Is it possible to check the Solana program `macro` correctness before deployment?

50 views Asked by At

When we want to deploy program to Solana, first we need to generate the program keypair and insert the public key in my declare_id! macro in lib.rs.

for example:

use anchor_lang::{prelude::*, solana_program::pubkey};

// this one
declare_id!("3qoBD26MJXRaCqgURhcRP2sz1U9pNoskVjLwzx62S5KE");

#[program]
mod anchor_example {
    use anchor_lang::solana_program::system_instruction;

    use super::*;

    pub fn initialize(ctx: Context<Initialize>, data: u64, authority: Pubkey) -> Result<()> { 
....

Because I want to expose an API interface for user to upload their .so file & specify the expected program ID, and I'll do the uploading for them(I'll manage their keypair btw).

Just wondering if it is possible to detect if the pubkey inside declare_id! is equal to the expected program ID input by user before actual deployment?

So that I can tell the user that he is inserting the wrong pubkey inside his solana program.

Thanks

0

There are 0 answers