I faced the same error and while I was searching for a solution, I found your question. It was the exact same problem I had. Thankfully, I found the solution.
I was following a tutorial here
When I started getting the error:
spl-token create-account <token_address>
Creating account <token_account_address>
Error: Client(Error { request: Some(SendTransaction), kind: RpcError(RpcResponseError { code: -32002, message: "Transaction simulation failed: Error processing Instruction 0: incorrect program id for instruction", data: SendTransactionPreflightFailure(RpcSimulateTransactionResult { err: Some(InstructionError(0, IncorrectProgramId)), logs: Some(["Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke 1", "Program log: Create", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]", "Program log: Instruction: GetAccountDataSize", "Program log: Error: IncorrectProgramId", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 884 of 194603 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: incorrect program id for instruction", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 6281 of 200000 compute units", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: incorrect program id for instruction"]), accounts: None, units_consumed: Some(6281), return_data: None }) }) })
I used the spl-token create-token
command to create the token locally. Then I used spl-token create-account <token_address> --url https://api.devnet.solana.com
to try to create an account for the token on the devnet when I got the error above.
I later realised that I created a token on my local node and tried to create an account for it on the devnet which is why the error says: Transaction simulation failed: Error processing Instruction 0: incorrect program id for instruction
So the fix was to create the token again but this time on the devnet using: spl-token create-token --url https://api.devnet.solana.com
and then create an account for the token with the token address on devnet using:
spl-token create-account <token_address> --url https://api.devnet.solana.com
The cause of the error are two things:
- The inconsistency in the creation of the token and the account i.e if you create the token locally and try to create account on devnet, you'll get the error
- If you are creating token on the devnet and your solana cli config is not set accordingly to read from the devnet, then you'll get this error.
So to avoid this error, choose according to your project use case where you want the token and it's account to be ( local or devnet) then configure your solana cli config accordingly.
Solana CLI config quick commands:
- Check config current settings:
solana config get
- Set default RPC cluster to Solana devnet:
solana config set -ud
- Set default RPC cluster to localhost :
solana config set --url localhost --keypair <PATH_TO_WALLET> e.g /home/solana/my_wallet.json