Skip to main content
clarification
Source Link

I'd like to define something like:

pub mod mints {
    use solana_program::{pubkey, pubkey::Pubkey};
    pub const USDC: Pubkey = pubkey!("key");
}

But then be able to access it with mints::USDC and have the value be environment dependent.

Is this possible? How do I achieve this with either just solana/rust or within Anchor?

I'd like to define something like:

pub mod mints {
    use solana_program::{pubkey, pubkey::Pubkey};
    pub const USDC: Pubkey = pubkey!("key");
}

I'd like to define something like:

pub mod mints {
    use solana_program::{pubkey, pubkey::Pubkey};
    pub const USDC: Pubkey = pubkey!("key");
}

But then be able to access it with mints::USDC and have the value be environment dependent.

Is this possible? How do I achieve this with either just solana/rust or within Anchor?

Source Link

How do you define constants with the same name but for differents networks?

I'd like to define something like:

pub mod mints {
    use solana_program::{pubkey, pubkey::Pubkey};
    pub const USDC: Pubkey = pubkey!("key");
}