Search code examples
blockchainsolananftmetaplexcandy-machine

Implementing "create NFT" onClick using Metaplex


I want to create/upload NFTs using metaplex on button click. I have the metadata json file an the nft artwork in a folder. They have to be uploaded to candy machine in a button click. Please help me out.


Solution

  • The Best Way to do this is using the Metaplex/js SDK because in Candy Machine the metadata is stored on-chain in an account and the mint Happens in Random order So it does not guarantee you that the user pressing the button is going to get the exact same NFT. So i would suggest you use the JS SDK it contains a function called create which can mint an NFT on-demand provided the metadata beforehand.

    const { nft } = await metaplex
    .nfts()
    .create({
        uri: "https://arweave.net/123",
        name: "My NFT",
        sellerFeeBasisPoints: 500; // Represents 5.00%.
    })
    .run();