I am trying to use the "createInitializeMintInstruction()" using JS to create a token. The problem is when executing, it throws an error. Concretely this one:
Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction
logs: [
'Program 11111111111111111111111111111111 invoke [1]',
'Program 11111111111111111111111111111111 success',
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
'Program log: Instruction: InitializeMint',
'Program log: Error: InvalidAccountData',
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1547 of 399850 compute units',
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: invalid account data for instruction'
]
}
The function createInitializeMintInstruction()
asks for the following parameters:
@parameter mint, @parameter decimals, @parameter mintAuthority, @parameter freezeAuthority (optional) and the token program @parameter programId.
Before calling the createInitializeMintInstruction()
, I create an account that will be the mint for the token using the following instruction: SystemProgram.createAccount()
(using the TOKEN_PROGRAM_ID as well when creating the account).
The account is created succesfully and I pass the parameters correctly to the initializeMint instruction. I don't see why the invalid account data.
By the way, I'm using TOKEN_PROGRAM_ID
from @solana/spl-token
Any help is appreciated, thank you.