I'm trying to revoke the mint authority in my code using Anchor. I've tried many things, but I always get an error during deployment. Whenever I add set_authority to my code, I encounter the following error during deployment:
Error: Deploying program failed: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: account data too small for instruction [3 log messages] There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: '', stderr: '' }.
When set_authority is not included, the deployment works fine. Does anyone know what might be causing this issue and how to resolve it? pub fn mint_tokens(ctx: Context, quantity: u64) -> Result<()> { let seeds = &["mint".as_bytes(), &[ctx.bumps.mint]]; let signer = [&seeds[..]];
mint_to(
CpiContext::new_with_signer(
ctx.accounts.token_program.to_account_info(),
MintTo {
authority: ctx.accounts.mint.to_account_info(),
to: ctx.accounts.destination.to_account_info(),
mint: ctx.accounts.mint.to_account_info(),
},
&signer,
),
quantity,
)?;
set_authority(
CpiContext::new_with_signer(
ctx.accounts.token_program.to_account_info(),
SetAuthority {
account_or_mint: ctx.accounts.mint.to_account_info(),
current_authority: ctx.accounts.mint.to_account_info(),
},
&signer,
),
spl_token::instruction::AuthorityType::MintTokens,
None, // Entferne die Mint-Authority
)?;
Ok(())
}
//Account:
#[derive(Accounts)]
pub struct MintTokens<'info> {
#[account(
mut,
seeds = [b"mint"],
bump,
mint::authority = mint,
)]
pub mint: Account<'info, Mint>,
#[account(
init_if_needed,
payer = payer,
associated_token::mint = mint,
associated_token::authority = payer,
)]
pub destination: Account<'info, TokenAccount>,
#[account(mut)]
pub payer: Signer<'info>,
pub rent: Sysvar<'info, Rent>,
pub system_program: Program<'info, System>,
pub token_program: Program<'info, Token>,
pub associated_token_program: Program<'info, AssociatedToken>,
}