) -> Result<()> { msg!("PDA account created successfully"); Ok(()) } } #[derive(Accounts)] pub struct CreatePdaAccount<'info> { #[account(mut)] pub payer: Signer<'info>, #[account( init, payer = payer, space = 8 + 32 + 8 + 1, // discriminator + owner + staked_amount + bump seeds = [b"client1", payer.key().as_ref()], bump )] pub pda_account: Account<'info, StakeAccount>, pub system_program: Program<'info, System>, }"> ) -> Result<()> { msg!("PDA account created successfully"); Ok(()) } } #[derive(Accounts)] pub struct CreatePdaAccount<'info> { #[account(mut)] pub payer: Signer<'info>, #[account( init, payer = payer, space = 8 + 32 + 8 + 1, // discriminator + owner + staked_amount + bump seeds = [b"client1", payer.key().as_ref()], bump )] pub pda_account: Account<'info, StakeAccount>, pub system_program: Program<'info, System>, }"> ) -> Result<()> { msg!("PDA account created successfully"); Ok(()) } } #[derive(Accounts)] pub struct CreatePdaAccount<'info> { #[account(mut)] pub payer: Signer<'info>, #[account( init, payer = payer, space = 8 + 32 + 8 + 1, // discriminator + owner + staked_amount + bump seeds = [b"client1", payer.key().as_ref()], bump )] pub pda_account: Account<'info, StakeAccount>, pub system_program: Program<'info, System>, }">
use anchor_lang::prelude::*;
use anchor_lang::system_program;
declare_id!("YourProgramIdHere111111111111111111111111111");
#[program]
pub mod your_program {
use super::*;
pub fn create_pda_account(ctx: Context<CreatePdaAccount>) -> Result<()> {
msg!("PDA account created successfully");
Ok(())
}
}
#[derive(Accounts)]
pub struct CreatePdaAccount<'info> {
#[account(mut)]
pub payer: Signer<'info>,
#[account(
init,
payer = payer,
space = 8 + 32 + 8 + 1, // discriminator + owner + staked_amount + bump
seeds = [b"client1", payer.key().as_ref()],
bump
)]
pub pda_account: Account<'info, StakeAccount>,
pub system_program: Program<'info, System>,
}