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 3: An account required by the instruction is missing #110

Open
strickland84 opened this issue Mar 26, 2024 · 1 comment

Comments

@strickland84
Copy link

I am trying to create a Fungible SPL-2022 token with metaplex. I believe I'm missing some key piece of the puzzle here so help would be appreciated. My pseudo-code looks like this:

import useUmi from '@/hooks/useUmi'
import { TokenStandard, createV1, mintV1 } from '@metaplex-foundation/mpl-token-metadata'
import { percentAmount, generateSigner, signerIdentity, sol, transactionBuilder, publicKey} from '@metaplex-foundation/umi'

umi.use(signerIdentity(umi.identity));
const mint = generateSigner(umi);

const SPL_TOKEN_2022_PROGRAM_ID = publicKey(
  'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'
);

const transaction = transactionBuilder()
  .add(createV1(umi, {
    mint,
    authority: umi.identity,
    name: token.name,
    symbol: token.symbol,
    uri: metaDataUri,
    sellerFeeBasisPoints: percentAmount(0),
    decimals: token.decimals,
    splTokenProgram: SPL_TOKEN_2022_PROGRAM_ID,
    tokenOwner: umi.identity.publicKey,
    tokenStandard: TokenStandard.Fungible
  }))
  .add(mintV1(umi, {
    mint: mint.publicKey,
    authority: umi.identity.publicKey,
    tokenOwner: mint.publicKey,
    splTokenProgram: SPL_TOKEN_2022_PROGRAM_ID,
    tokenStandard: TokenStandard.Fungible
  }))

transaction.sendAndConfirm(umi).then(() => {
  // Do something
}).catch((error) => {
  console.log(error)
});

When I run this function I receive error:

Transaction simulation failed: Error processing Instruction 3: An account required by the instruction is missing

If I skip preflight, I receive error:

{
    "InstructionError": [
        3,
        "MissingAccount"
    ]
}

Can anyone help enlighten me? What am I missing here? Thanks!

@MarkSackerberg
Copy link
Contributor

Hey @strickland84
there seems to be an issue in how umi derives the token account?

import { findAssociatedTokenPda } from '@metaplex-foundation/mpl-toolbox'

  const token = findAssociatedTokenPda(umi, {
    mint: mint.publicKey,
    owner: umi.identity.publicKey,
    tokenProgramId: SPL_TOKEN_2022_PROGRAM_ID,
  });
  
const transaction = transactionBuilder()
  .add(createV1(umi, {
    mint,
    authority: umi.identity,
    name: token.name,
    symbol: token.symbol,
    uri: metaDataUri,
    sellerFeeBasisPoints: percentAmount(0),
    decimals: token.decimals,
    splTokenProgram: SPL_TOKEN_2022_PROGRAM_ID,
    tokenOwner: umi.identity.publicKey,
    tokenStandard: TokenStandard.Fungible
  }))
  .add(mintV1(umi, {
    mint: mint.publicKey,
    authority: umi.identity.publicKey,
    token,
    tokenOwner: mint.publicKey,
    splTokenProgram: SPL_TOKEN_2022_PROGRAM_ID,
    tokenStandard: TokenStandard.Fungible
  }))

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

2 participants