Hi I got a project written by a team of devs that left the project, and I successfully ran it locally (on my computer) and I changed it to use devnet. I'm getting this error: Error: AnchorError caused by account: owner. Error Code: AccountOwnedByWrongProgram. Error Number: 3007. Error Message: The given account is owned by a different program than expected.

When it's running the following command, then it will fail with the above message:

await program.rpc.new(
        (tokenPrice * Number(`1e${tokenInfo.value.decimals}`)) / 1000000,
          accounts: {
            systemProgram: web3.SystemProgram.programId,
            user: this.wallet.publicKey,
            sportClubAccount: sportClubAddress,
            games: gameAddress.publicKey,
            jackpotAccount: !!splAccount.value[0]
              ? splAccount.value[0]?.pubkey
              : jackpot.publicKey,
            owner: ownerAddress,
          signers: [gameAddress],
          options: this.optionsConfig(slot),

I logged the variables as follows:

(tokenPrice * Number(`1e${tokenInfo.value.decimals}`)) / 1000000 = 2000
    "tokenPrice": 2,
    "tokenInfo.value.decimals": 9,
    "mintAddress": "HHZsnr3kspMkoBzXusN3EbgoPL7YwSgNgaiUSg6QZdks",
    "sportClubPercent": "0.4",
    "ownerPercent": "0.6",
    "minPrizePool": "4",
    "accounts": {
        "games": "BkJchhHAQ36KnCzNCWohZ7dcyLrhPsn9mHZiiSKPHe84",
        "user": "7ZnJs1GKLCgLX2o54HzPqfPTWnncfHGeX6kcvD47BZLM",
        "jackpotAccount": "Dn4GgpMTiyw1E8yxaMSmt1wAHeK6yfjfy9gn9gRNuNdp",
        "owner": "7ZnJs1GKLCgLX2o54HzPqfPTWnncfHGeX6kcvD47BZLM",
        "sportClubAccount": "6F7D9EVt1UDzoMKqP4Bxut1ke927JDzQqNv5z8dm9GsX",
        "systemProgram": "11111111111111111111111111111111"

7ZnJs1GKLCgLX2o54HzPqfPTWnncfHGeX6kcvD47BZLM is the owner of the token address HHZsnr3kspMkoBzXusN3EbgoPL7YwSgNgaiUSg6QZdks

Program address is (devnet): 8g4k52qaEC34Nev4b6QsPAnU5JEdkfTmAypgCpecDiLK

in the Rust side:

pub mod contracts {

pub fn new(ctx: Context<InitializeGame>, enter_amount: f64, token_account: Pubkey, sport_club_percent: f64, owner_percent: f64, min_jackpot: f64) -> anchor_lang::Result<()> {
    let new_game_account = &mut ctx.accounts.games;
    new_game_account.enter_amount = enter_amount;
    new_game_account.owner = ctx.accounts.owner.key();
    new_game_account.token_account = token_account;
    new_game_account.jackpot_account = ctx.accounts.jackpot_account.key(); 
    new_game_account.sport_club_account = ctx.accounts.sport_club_account.key(); 
    new_game_account.prize_pool = 0.0;
    new_game_account.is_active = true;
    new_game_account.sport_club_percentage = sport_club_percent;
    new_game_account.owner_percentage = owner_percent;
    new_game_account.min_prize_pool = min_jackpot;

pub struct InitializeGame<'info> {
    #[account(init, payer = user, space = 32+32+32+1+32+8+8+24+8+8+8)]
    pub games: Account<'info, GameSpl>,
    pub user: Signer<'info>,
    pub jackpot_account: Account<'info, TokenAccount>,
    pub owner: Account<'info, TokenAccount>,
    pub sport_club_account: Account<'info, TokenAccount>,
    pub system_program: Program<'info, System>,

1 Answer 1


The problem that I've had is, I was not use the token account for the 'owner' and 'sportClubAccount', but I was using the account address.

The solution is to use token account address instead of account address as it's mentioned in the #[derive(Accounts)] in rust. Also jackpotAccount is a token account address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.