4

I'm trying to create a feature on my web page where the user is able to create their own collection of nfts. To make these I follow these workflow:

  1. The user want to create a collection of 5000 nfts for example

  2. I create the arweave link of every nfts using bundlr (mostly using the uploadAll method of metaplex)

  3. I create the nft (mostly using the metaplex.nfts().create() method)

My code is something like these:

To make 2)

// I upload all the images (pngs)
console.log("procesing images", metaplexFiles)
const imageLinks = await metaplex.storage().uploadAll(metaplexFiles)

// Later on I put the images inside the json and create the arweaveLinks
  metaplexFiles = filePairs.map(({manifest}) => manifest as MetaplexFile)
  console.log("A metaplex file", metaplexFiles)
  const arweaveLinks = await metaplex.storage().uploadAll(metaplexFiles)

enter image description here

These simple code gives me 3 approvals

1 of these

enter image description here

And 2 of these

enter image description here

To make 3)

I use a code like these

 /**
 * Mint assets  with the metaplex SDK
 */
export async function mintNfts( collectionNFt: Nft, arweaveLinks: string[], wallet: WalletContextState, connection: Connection): Promise<Nft[]> {
  const metaplex = getMetaplexConfig(connection, wallet)

  const { results } = await PromisePool.withConcurrency(20)
  .for(arweaveLinks)
  .handleError(async (err) => {
    console.log(`Could not complete the transaction successfully, exiting due to:`, err);
    throw err;
  })
  .onTaskFinished((user, pool) => {
    // retrieve the number of items processed in the pool
    console.log(`${pool.processedCount()}/${arweaveLinks.length} proccesed`)
  })
  .process(async (link) => {
    console.log("creating an NFT")
    const { nft } = await metaplex.nfts().create({
      uri: link,
      isMutable: true,
      collection: {
        verified: false,
        key: collectionNFt.mint
      }
    });
    return nft;
  })

  return results;
}

That gives me just these approval

enter image description here

The final code will look like these

const arweaveLinks = await upload(files, nftForm.licence, wallet, connection);
// console.log("arweaveLinks", arweaveLinks);

const nfts = await mintNfts(collectionNft, arweaveLinks, wallet, connection);

These number of transaction that I show is just for 1 NFT the problem is that if the number of NFTs increases the number of transactions to approve increases too, so if the user want to mint around 1000 NFTs will have to approve more than 1000 popups of phantom.

These is my problem, I want to find a way to make all these workflow with as many as approves as possible, maybe with 1 o max 3 approves... There is a way to make these?

Any help appreciated. Thanks

1 Answer 1

1

Hey Frank there are a couple of ways in which the problem outlined here can be solved. Since you are using Bundlr to upload it will ask you everytime to upload the asset and the arweave url is something that cannot be determined before hand so if you plan to do it from an UI than unfortunately the user has to go through that pain to solve particularly this problem you can either use IPFS to store asset image and metadata as it does not required signing or if you really wanna use arweave for storage than you can have a Backend service that does the signing on behalf of the user and pay some sol from the backend for covering the upload costs.

For Minting many NFT at once you need to make sure all the minting ix that you have added in the transaction are less than 1232 bytes and i think it would only allow 1-2 NFTs with this amount of bytes one work around for this can be to have a backend service which airdrops NFT to the user wallet in multiple transaction. In doing this the user does not have to sign a transaction multiple times its the backend service that will do that so makes the experience better.

4
  • So these problem of the approve to generate the arweave links is because of bundlr ? So in general the best approach to these is do a backend service that does all these work... Commented Jul 15, 2022 at 20:28
  • Ya arweave uses bundlr and bundlr needs some SOL to upload your file and give you links you can either take this process to your backend or use some other storage method
    – Pratik.js
    Commented Jul 16, 2022 at 5:37
  • The problem that I'm seeing with this approach is that when comes the moment to transfer the NFTs in bulk from our wallet to the wallet of the user, don't will be problematic? I have try to send NFTs in bulk before and it's a little of problematic, sometimes gives an error... Commented Aug 1, 2022 at 13:40
  • Ya bulk transfer is multiple transfer ix in one transaction and the transaction object has a limit of 1232 bytes as of now which would be overcome by lookup tables which is still a work in progress.So you have to transfer n number of NFTs within the limit of 1232 bytes unfortunately.
    – Pratik.js
    Commented Aug 1, 2022 at 13:52

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.