Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction simulation failed: Error processing Instruction 0: incorrect program id for instruction", #461

Open
thekingisherenow opened this issue Nov 10, 2024 · 0 comments

Comments

@thekingisherenow
Copy link

I keep on getting this error while creating associated token, wbout the wrong program ID. The sccoaited token address got from the getter function is also not in chain- when I did solana_client.get_account_info of the value from getters of associated tokne, the value is none. showing that it doesnt exits..
When I try to create it and send transaction, fails with incorrect program id.

I am using usdc as example. and wish to create asscoaited key of sender to that token. this error shows up:

from solana.rpc.async_api import AsyncClient
from spl.token.constants import TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID
from solders.pubkey import Pubkey

solana_client = AsyncClient("https://api.devnet.solana.com")
res = await solana_client.is_connected()
print("isConnected?", res) # True

    sender_key_pair = await load_private_key('sender.json')
    receiver_key_pair = await load_private_key('receiver.json')

    token_address = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"

    # Directly create the Pubkey from the Base58 string
    token_address_public_key = Pubkey.from_string(token_address)

    # # Create token client
    token_client = AsyncToken(
        solana_client, token_address_public_key, TOKEN_PROGRAM_ID, sender_key_pair)

    sender_associated_token_address = get_associated_token_address(
        sender_key_pair.pubkey(), token_address_public_key)
    print("sender_associated_token_address",
          sender_associated_token_address)

    create_ata_instruction = create_associated_token_account(
        payer=sender_key_pair.pubkey(),
        owner=receiver_key_pair.pubkey(),
        mint=token_address_public_key
        # , token_program_id=TOKEN_PROGRAM_ID
    )
    msg = Message([create_ata_instruction], sender_key_pair.pubkey())
    latest_blockhash = (await solana_client.get_latest_blockhash()).value.blockhash
    transaction_signature_response = await solana_client.send_transaction(Transaction([sender_key_pair], msg, latest_blockhash))
    print("transaction_signature_response",
          transaction_signature_response)

Output : Transaction failed with error: SendTransactionPreflightFailureMessage { message: "Transaction simulation failed: Error processing Instruction 0: incorrect program id for instruction", data: RpcSimulateTransactionResult(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 192908 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: incorrect program id for instruction", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 7976 of 200000 compute units", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: incorrect program id for instruction"]), accounts: None, units_consumed: Some(7976), return_data: None, inner_instructions: None }) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant