9

I am having this error when processing instructions for a transaction.

Detail error log:

Transaction simulation failed: Error processing Instruction 1: Provided owner is not allowed 
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]
    Program log: Create
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]
    Program log: Instruction: GetAccountDataSize
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1622 of 992908 compute units
    Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program 11111111111111111111111111111111 invoke [2]
    Program 11111111111111111111111111111111 success
    Program log: Initialize the associated token account
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]
    Program log: Instruction: InitializeImmutableOwner
    Program log: Please upgrade to SPL Token 2022 for immutable owner support
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 986418 compute units
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]
    Program log: Instruction: InitializeAccount3
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4241 of 982534 compute units
    Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 22045 of 1000000 compute units
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]
    Program log: Create
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 5209 of 977955 compute units
    Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: Provided owner is not allowed

This is how the instruction is constructed:

const provider = new anchor.AnchorProvider(connection, wallet as any, {});
const gameProgram = new Program(
  gameIdl as Idl,
  gameProgramId,
  provider
);

const gameKeypair = anchor.web3.Keypair.generate();
const gameId = gameKeypair.publicKey;
const fixedGameKeypair = anchor.web3.Keypair.generate();

const [gameSigner, _bump] = await anchor.web3.PublicKey.findProgramAddress(
  [gameKeypair.publicKey.toBytes()],
  gameProgram.programId
);

const escrowTicketTokenAccount = await getAssociatedTokenAddress(
  new PublicKey(ticketMint),
  gameSigner,
  true
);
const escrowPrizeTokenAccount = await getAssociatedTokenAddress(
  new PublicKey(prizeMint),
  gameSigner,
  true
);

const ticketTokenAccount = await getAssociatedTokenAddress(
  ticketMint,
  wallet.publicKey
);
const prizeTokenAccount = await getAssociatedTokenAddress(
  prizeMint,
  wallet.publicKey
);

const initTokenAccountsInstruction = [
  createAssociatedTokenAccountInstruction(
    wallet.publicKey, // payer
    escrowTicketTokenAccount, // ata
    gameSigner, // owner
    ticketMint // mint
  ),
  createAssociatedTokenAccountInstruction(
    wallet.publicKey, // payer
    escrowPrizeTokenAccount, // ata
    gameSigner, // owner
    prizeMint // mint
  ),
];

const accounts = {
  payer: wallet.publicKey,
  ticketMint,
  prizeTokenAccount,
  prizeMint,
  game: gameId,
  gameSigner,
  systemProgram: SystemProgram.programId,
  tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
  escrowPrizeTokenAccount,
  fixedGame: fixedGameKeypair.publicKey,
};

const params = {
  ...args,
  bump: _bump,
};
const tx = await gameProgram.methods
  .createGame(params)
  .accounts(accounts)
  .preInstructions([
    ...initTokenAccountsInstruction,
    SystemProgram.createAccount({
      fromPubkey: wallet.publicKey,
      newAccountPubkey: gameId,
      programId: gameProgram.programId,
      lamports: await connection.getMinimumBalanceForRentExemption(
        8 + 32 * 4 + 8 * 9 + 1 * 4 + 2 + 1 + 1 + 35 * args.maxEntries.toNumber()
      ),
      space:
        8 +
        32 * 4 +
        8 * 9 +
        1 * 4 +
        2 +
        1 +
        1 +
        35 * args.maxEntries.toNumber(),
    }),
    SystemProgram.createAccount({
      fromPubkey: wallet.publicKey,
      newAccountPubkey: fixedGameKeypair.publicKey,
      programId: gameProgram.programId,
      lamports: await connection.getMinimumBalanceForRentExemption(
        8 + 32 + 4 + 35 * args.maxEntries.toNumber()
      ),
      space: 8 + 32 + 4 + 35 * args.maxEntries.toNumber(),
    }),
  ])
  .signers([gameKeypair, fixedGameKeypair])
  .rpc();

This code works for me on devnet, but failing on mainnet! The log is really vague to me and couldn't search it anywhere, my biggest guess is that the owner of the associated token account is a PDA (not on curve). Please help, thanks for your time!

1
  • Did you manage to solve this? Commented Sep 9, 2022 at 12:27

2 Answers 2

1

Yes you derived the PDA above which is the owner of the ATAs you need to pass in the bump seed to sign that ix afaik

0

Make sure the wallet approving the TX is connected to the right network.

If you're performing the TX on devnet but your wallet is still connected on main-net you'll get this error.

3
  • is there a way to get the right network connected via the wallet btw @harkl?
    – viksit
    Commented Jan 18, 2023 at 22:11
  • In wallet settings you can select the network. I use Glow at the moment and network is located in ⚙️ button.
    – harkl
    Commented Jan 19, 2023 at 3:56
  • ohh i meant in the code! eg when a wallet shifts from devnet to mainnet..
    – viksit
    Commented Feb 3, 2023 at 14:34

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.