0

I am trying to simulate minting 100 tokens to a wallet address and when I start the program, I get thrown this error: TokenAccountNotFoundError This is the typescript code for creating the token account:

  connection: web3.Connection,
  payer: web3.Keypair,
  mint: web3.PublicKey,
  owner: web3.PublicKey
) {
  const tokenAccount = await token.getOrCreateAssociatedTokenAccount(
      connection,
      payer,
      mint,
      owner,
  )
  
  console.log(
      `Token Account: https://explorer.solana.com/address/${tokenAccount.address}?cluster=devnet`
  )

  return tokenAccount
}

1 Answer 1

1

I assume getOrCreateAssociatedTokenAccount transaction is just sent but not fully confirmed before the mint transaction is sent. You should wait until trnasction is confirmed.

I am not sure what the token object you used is but the default createAssociatedTokenAccount in @solana/spl-token library confirms transaction internally.

https://github.com/solana-labs/solana-program-library/blob/48fbb5b7/token/js/src/actions/createAssociatedTokenAccount.ts#L41

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.