metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
357 stars 182 forks source link

Error when trying to mint collection nft #416

Closed fallenangel2305 closed 1 year ago

fallenangel2305 commented 1 year ago
metaplex.nfts().create({
        name: "test",
        sellerFeeBasisPoints: 200,
        uri: "http://example.com/",
        isMutable: true,
        isCollection: true,
        collectionIsSized: true,
      }).then(nft => {
        console.log(nft, "test collection nft")
      })

ERROR

read-write.ts:28 Uncaught (in promise) AssertionError [ERR_ASSERTION]: We shouldn't ever need to resize, but 1 > 0
    at BeetWriter.maybeResize (read-write.ts:28:1)
    at BeetWriter.write (read-write.ts:38:1)
    at BeetWriter.writeStruct (read-write.ts:46:1)
    at BeetStruct.serialize (struct.ts:103:1)
    at FixableBeetArgsStruct.serialize (struct.fixable.ts:76:1)
    at createCreateMetadataAccountV3Instruction (CreateMetadataAccountV3.ts:78:1)
    at createSftBuilder (createSft.ts:444:1)
    at async createNftBuilder (createNft.ts:393:1)
    at async Object.handle (createNft.ts:280:1)
    at async Disposable.run (Disposable.ts:33:1)
fallenangel2305 commented 1 year ago
import {
  clusterApiUrl,
  Connection,
  Keypair,
  LAMPORTS_PER_SOL,
} from "@solana/web3.js";
import { keypairIdentity, Metaplex, sol } from "@metaplex-foundation/js";
import Fs from "@supercharge/fs";

async function main() {

  const connection = new Connection(clusterApiUrl("mainnet-beta"));
  const metaplex = new Metaplex(connection);

  const collectionAuthority = Keypair.fromSecretKey(
    new Uint8Array(
      JSON.parse(
        //replace with actual path from home dir. For example '.config/solana/devnet.json'
        Fs.readFileSync(
          Fs.homeDir(
            ".config/solana/your_keypair.json"
          )
        ).toString()
      )
    )
  );

  // const collectionAuthority = Keypair.generate();

  metaplex.use(keypairIdentity(collectionAuthority));
  const { nft: collectionNft } = await metaplex.nfts().create({
    name: "My Collection NFT",
    uri: "https://example.com/path/to/some/json/metadata.json",
    sellerFeeBasisPoints: 0,
    isCollection: true,
    updateAuthority: collectionAuthority,
  });
  console.log(collectionNft.address.toBase58(), "collection nft address");
}
main();

this is a test in ts-node which works but when i try to create collection nft in react with javascript i get the above error

github-actions[bot] commented 1 year ago

Hi @fallenangel2305,

Thank you for your question!

We'd like to make sure our GitHub issue tracker remains the best place to manage issues that affect the development of the Metaplex JS SDK itself.

Your question deserves a purpose-built Q&A forum like StackOverflow so it is more searchable and encourages others to contribute to and benefit from the answer.

Unless there exists evidence that this is a bug with the JS SDK itself, would you please post your question to the Solana Stack Exchange using the following link:

https://solana.stackexchange.com/questions/ask?tags=metaplex

If you could please share the link to the newly created question here afterwards, that would be very helpful for anyone following this thread.


This automated message is a result of having added the "question" label.