MintAccount can't be found

1.3k views Asked by At

I want to create an NFT using the Metaplex SDK with react. But when i execute this function, it throws following error:

AccountNotFoundError: 
The account of type [MintAccount] was not found at the provided address 
[7SYH47nGcK5fnMmf6zoW75BWpdxDAyq8DBRbagMdsPKJ].

This is the function i'm trying to execute:

  async function mint() {
    const links = await uploadMetadata();
    console.log("Cover: " + links.cover);
    console.log("Text: " + links.text);
    console.log("Metadata: " + links.metadata);
    const { nft } = await metaplex.nfts().create({
      uri: links.metadata,
      name: title,
      sellerFeeBasisPoints: 500, // Represents 5.00%.
    });
    console.log(nft);
  }```
4

There are 4 answers

3
Jimii On BEST ANSWER

This is a metaplex SDK error.

The issues is that metaplex sdk is trying to read after writing to solana. The issues with that is obviously that the changes have yet to be propagated throughout the chain.

To fix this add the optional commitment argument { commitment: "finalized" }

Your code will now look like this


async function mint() {
    const links = await uploadMetadata();
    console.log("Cover: " + links.cover);
    console.log("Text: " + links.text);
    console.log("Metadata: " + links.metadata);
    const { nft } = await metaplex.nfts().create(
        {
            uri: links.metadata,
            name: title,
            sellerFeeBasisPoints: 500, // Represents 5.00%.
        },
        { commitment: "finalized" }
    );
    console.log(nft);
}
0
Luis Pedro Bonomi On

This worked for me:

const transactionBuilder = await metaplex.nfts().builders().create({ ... });
const { mintAddress } = transactionBuilder.getContext();
await metaplex.rpc().sendAndConfirmTransaction(transactionBuilder);

// Then, optionally fetch the NFT afterwards after sleeping for 2 seconds. 
await new Promise(resolve => setTimeout(resolve, 2000))
const nft = await metaplex.nfts().findByMint({ mintAddress });

From https://github.com/metaplex-foundation/js/issues/344#issuecomment-1325265657

0
lmbrd On

try to add "confirmed" to your solana connection, for example:

const SOLANA_CONNECTION = new Сonnection("https://api.devnet.solana.com", "confirmed");

This should help

0
pepeIKO On

The way I "solved" this was to not use the methods like nfts().create({}) directly; instead, use them with the transaction builder module.

So this example would look like this:

const createNftBuilder = await metaplex.nfts().builders().create({
  uri: links.metadata,
  name: title,
  sellerFeeBasisPoints: 500, // Represents 5.00%.
});

// Get the data that you don't know in advance from getContext()
const { mintAddress } = transactionBuilder.getContext();

// Submit the tx
await metaplex
    .rpc()
    .sendAndConfirmTransaction(createNftBuilder, { commitment: "confirmed" });

This way, the SDK doesn't try to fetch the on-chain data too early. The problem is that you end up writing a lot more code and you can't get the nft object in the same way as above.