1
from spl.token.instructions import transfer, TransferParams
from spl.token.constants import TOKEN_PROGRAM_ID
from solana.rpc.api import Client
from solders.pubkey import Pubkey
from solana.transaction import Transaction

token = 'wbUyCKSNwbeeEXoaMDCk4rNqKXeH36Nt9A1FBnQbiiB'
http_provider='https://api.devnet.solana.com'
burn_address =  "11111111111111111111111111111111"
token_pub = Pubkey.from_string(token)


client = Client(http_provider)

transaction = Transaction().add(
    transfer(TransferParams(
        source=token_pub,
        dest=Pubkey.from_string(burn_address),
        owner=my_wallet,
        amount=10,
        program_id=TOKEN_PROGRAM_ID
    ))
)
client.send_transaction(transaction, wallet_key_pair)


I want to send my USDC mock coin to burn address

and

It results

"Program log: Error: InvalidAccountData", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1270 of 200000 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: invalid account data for instruction"

I can't understand which account is wrong

1 Answer 1

1

the InvalidAccountData means that you are passing in an account that is different from what was expected.

In your case, 11111111111111111111111111111111 is the SystemProgram, while the TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA is expecting a token account, which is owned by it for the dest.

Use the burn instruction that spl token library provides or create an ATA for this address 1nc1nerator11111111111111111111111111111111 which is mostly used for such operations.

2
  • burn_dest = Pubkey.find_program_address( [ bytes(my_wallet), bytes(TOKEN_PROGRAM_ID), bytes(token_pub) ], ASSOCIATED_TOKEN_PROGRAM_ID )[0] transaction = Transaction().add( burn(BurnParams( account=burn_dest, amount=1, mint=token_pub, owner=my_wallet, program_id=TOKEN_PROGRAM_ID )) ) Commented Jun 12 at 17:00
  • This works! Thanks so much Commented Jun 12 at 17:01

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.