What's the solidity equivalent to implement a mapping(address => bool)
in anchor for solana? I figured out the way to go is PDA, but I was only able to figure out how to generate a PDA using find_program_address
and create a PDA account using system_instruction::create_account
. I wanna know how to store and to retrieve value using the generated PDA with a variable like is_early_sale
,
#[account]
pub struct IsEarlySale
{
pub is_early_sale: bool
}
#[derive(Accounts)]
#[instruction(user: Pubkey)]
pub struct EarlySaleContext<'info>
{
#[account(
init,
payer = caller,
seeds = [user.key().as_ref()],
bump,
space = size_of::<IsEarlySale>() + 16
)]
pub set_pda_account: Account<'info, IsEarlySale>,
#[account(mut)]
pub caller: Signer<'info>,
pub system_program: Program<'info,System>,
#[account(mut)]
/// CHECK: This account is used to receive SOL.
pub program_account: AccountInfo<'info>
}