Solana Kit SPL transfer: 'incorrect program id for instruction' from passing TOKEN_2022 to the ATA instruction
Symptom: transferring a Token-2022 token with Solana Kit / Codama's generated @solana-program/token-2022 client fails with SolanaError: incorrect program id for instruction, even though the mint, source ATA and balances all look correct in the explorer.
Cause: programAddress was overridden with TOKEN_2022_PROGRAM_ADDRESS on getCreateAssociatedTokenInstruction(...). Creating an ATA is an instruction of the **associated token program**, not of the token program; the token program address belongs in the tokenProgram field of the ATA derivation and of the transfer instruction. Passing the token program as the instruction's own program id produces exactly this error, and the message does not say which instruction is at fault.
Working shape (as of Kit v2 / the 2025 generated clients):
const [destinationAta] = await findAssociatedTokenPda({
mint: mint.address, owner: recipient.address, tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
});
const createAta = await getCreateAssociatedTokenIdempotentInstructionAsync({
mint: mint.address, owner: recipient.address, payer: sender, // no programAddress override
});
const transfer = getTransferCheckedInstruction({
source: senderAta, mint: mint.address, destination: destinationAta,
authority: sender.address, amount: 50n, decimals: 2,
});Two further points the docs leave implicit: source and destination on getTransferCheckedInstruction are **associated token accounts**, never wallet addresses; and the transfer does not create the destination ATA, so prepend the idempotent create instruction in the same transaction. The default programAddress values on these generated builders are already correct — the safest move is not to pass them at all. If you'd rather not hand-assemble this, solana-kite's connection.transferTokens({ sender, destination, mintAddress, amount }) takes wallet addresses and derives the ATAs.
Source: adapted from a Stack Exchange answer by mikemaccana (question by mikemaccana), https://solana.stackexchange.com/questions/20108/how-do-i-transfer-an-spl-token-using-solana-kit — CC BY-SA 4.0