I am trying to create a functionality where the admin can fund SPL tokens in the pool and any other user can claim from that pool.
I am using global authority as the authority for the pool address
pub struct CreateTweet<'info> {
#[account(mut)]
pub user: Signer<'info>,
#[account(init, payer = user, seeds = [b"tweets", user.key().as_ref(), &[my_id as u8], &[my_id2 as u8]], bump, space = 64,)]
pub tweetData: Account<'info, MyTweet>,
#[account(
mut,
seeds = [GLOBAL_AUTHORITY_SEED.as_ref()],
bump = global_bump,
)]
pub global_authority: Account<'info, GlobalPool>,
#[account(
init,
payer = user,
seeds = [b"pool", user.key().as_ref(), tweetData.key().as_ref()],
bump,
token::mint = pool_mint,
token::authority = global_authority,
)]
pub pool: Account<'info, TokenAccount>,
#[account(mut)]
pub user_ata: Account<'info, TokenAccount>,
pub pool_mint: Account<'info, Mint>,
pub system_program: Program<'info, System>,
pub token_program: Program<'info, Token>,
pub rent: Sysvar<'info, Rent>,
}
this is my function where I am transferring SPL tokens from pool to user token account
let seeds = &[GLOBAL_AUTHORITY_SEED.as_bytes(), &[global_bump]];
let signer = &[&seeds[..]];
token::transfer(
CpiContext::new_with_signer(
ctx.accounts.token_program.to_account_info(),
token::Transfer {
from: ctx.accounts.pool.to_account_info(),
to: ctx.accounts.user_ata.to_account_info(),
authority: ctx.accounts.global_authority.to_account_info(),
},
signer
),
1000000000
)?;
But it is giving me an Error with code 0xbbf:
Error: #[msg("The given account is owned by a different program than expected")] AccountOwnedByWrongProgram
Also, the pool address is owned by the same address created with global authority seeds
Global authority address: https://explorer.solana.com/address/3Z3vN7UUoDcCWpYksnM5nj7BHgERQKhbKTEEXnnratk6?cluster=devnet
Pool (account) address: https://explorer.solana.com/address/FyJWLhuZase1mVpVraRHU6HBav9heHmS1Bu28NckRfSj?cluster=devnet