Skip to content

Instantly share code, notes, and snippets.

@kalloc
Created March 9, 2025 16:31
Show Gist options
  • Save kalloc/afd13af167806d94142f307a5391301c to your computer and use it in GitHub Desktop.
Save kalloc/afd13af167806d94142f307a5391301c to your computer and use it in GitHub Desktop.
use anchor_lang::prelude::*;
declare_id!("8UgrFcWWrTsme2yQ8xvWGtpKTgNoZmq8Lro9gFyksPJN");
#[program]
pub mod x {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
msg!("Greetings from: {:?}", ctx.program_id);
Ok(())
}
}
#[account]
#[derive(InitSpace)]
pub struct PdaState {
pub bump: u8,
pub is_authorized: bool,
pub pda_level: u8,
pub chance: u8,
pub module: bool,
pub bonus: Option<u8>,
pub mint: Pubkey,
#[max_len(5)]
pub races: Vec<u8>,
}
impl PdaState {
pub const SEED: &'static [u8] = b"state";
pub const MAX_SIZE: usize = 32 // admin
+ 8 // freeze until
+ 32 // treasury
+ 32 // bank
+ 32 // reward mint
+ 32 // active season
+ 1 + 50 * 32 // scheduled seasons
+ 1000 // padding
;
}
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(mut)]
pub payer: Signer<'info>,
#[account(
init,
seeds = [PdaState::SEED],
payer = payer,
space = 1000,
bump
)]
pub state: Account<'info, PdaState>,
pub system_program: Program<'info, System>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment