1

So I'm creating a Token2022 token for testing purposes right now, and I want to use the withdraw fee extension to hold a percentage on transfer and use my withdrawal authority account to capture those held fees into my account and use them for other purposes. This all works as expected, but I notice on certain occasions, the logic I have for creating a destination account for the token, and use that in the transfer instruction, sometimes it'll error out and say Error processing Instruction 0: incorrect program id for instruction. But it'll only do this 3 or 4 times before the transaction goes through.

Could this be a devnet issue, an RPC issue, or could this be related to priority fees? The Token-2022 program ID I'm passing down is definitely the correct one, so I'm not sure. This is part of the hook I wrote.

const transferWithFee = async(): Promise<void> => {
        try {
            const token = new PublicKey('')
            const sourceAccount = new PublicKey('')

            const accountKeypair = Keypair.generate();
            
            const destinationAccount = await createAccount(
                connection,
                owner,
                token,
                owner.publicKey,
                accountKeypair,
                undefined,
                TOKEN_2022_PROGRAM_ID
            );

            const transferAmount = BigInt(1000 * Math.pow(10, decimals)); // Transfer 1000 tokens
            const calcFee = (transferAmount * BigInt(feeBasisPoints)) / BigInt(10000); // expect 50 fee
            const fee = calcFee > maxFee ?  maxFee : calcFee;

            const transaction = new Transaction().add(
                createTransferCheckedWithFeeInstruction(
                    sourceAccount,
                    token,
                    destinationAccount,
                    sourceAccountOwner.publicKey,
                    transferAmount,
                    decimals,
                    fee,
                    [],
                    TOKEN_2022_PROGRAM_ID
                )
            );

            const sig = await sendAndConfirmTransaction(connection, transaction, [payer, sourceAccountOwner]);
            console.log('transfer sig: ', sig)
        } catch ( error ) {
            console.log('error minting and/or transferring token: ', error)
        }
    }
2
  • Is it possible that you're trying to create an account on a totally new mint, and the mint creation transaction hasn't been confirmed by the network yet? "Incorrect program id" could also mean that a token or mint account isn't properly initialized
    – Jon C
    Commented Jan 26 at 21:22
  • It's strange because it hasn't appeared since. Only happened once.
    – Brian M.
    Commented Mar 13 at 20:51

1 Answer 1

0

You need to specify the correct program id in your frontend.

See my answer in Getting "incorrect program id for instruction" when attempting to create a token account after creating a mint

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.