Reputation: 4389
I'm trying to mint some tokens on the frontend like this:
let transaction = new Transaction();
let mintToInstruction = Token.createMintToInstruction(
splToken.TOKEN_PROGRAM_ID,
myTokenMint.publicKey,
userAccount.publicKey,
airdropAdmin.publicKey,
[],
sendAmount.toNumber()
)
transaction.add(mintToInstruction);
let conn: Connection = ctx.connection;
const tx1 = await conn.sendTransaction(
transaction,
[airdropAdmin]
);
But I get an obscure error:
Error processing Instruction 0: invalid account data for instruction
What's happening?
Upvotes: 1
Views: 5609
Reputation: 4389
One of the accounts you're passing in is not the account the Token Program expected.
Either:
userAccount
is incorrect. This must be a Token Account, did you use the user's System Account instead?myMintAccount
is incorrect. Is this a real token mint?Consider logging those public keys and putting them into the explorer. Does the userAccount
say "Token Account" at the top? Does the myMintAccount
say "Token Mint"?
The invalid account data for instruction
typically happens when a program can't run unpack
on the data inside the account you're passing in.
So either the Account::unpack
is failing, or the the Mint::unpack
is failing.
Upvotes: 6