I'm using this fonction to mint a cNFT createMintToCollectionV1Instruction
but I don't want to wait 5-10sec before minting an other cNFT.
Has anyone found a solution to this problem?
2 Answers
You shouldn't have to wait to mint additional cNFTs, any rate limiting you're experiencing probably has to do with the RPC server you're using.
This was only on local net to test program that would interface with cNFTs, but I had this utility function that I invoked at the beginning of each test suite.
export async function setupTreeWithCompressedNFT(
connection: Connection,
payerKeypair: Keypair,
compressedNFT: MetadataArgs,
depthSizePair: ValidDepthSizePair = {
maxDepth: 14,
maxBufferSize: 64,
}
): Promise<{
merkleTree: PublicKey;
}> {
const payer = payerKeypair.publicKey;
const merkleTreeKeypair = Keypair.generate();
const merkleTree = merkleTreeKeypair.publicKey;
const space = getConcurrentMerkleTreeAccountSize(
depthSizePair.maxDepth,
depthSizePair.maxBufferSize
);
const allocTreeIx = SystemProgram.createAccount({
fromPubkey: payer,
newAccountPubkey: merkleTree,
lamports: await connection.getMinimumBalanceForRentExemption(space),
space: space,
programId: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
});
const [treeAuthority, _bump] = await PublicKey.findProgramAddress(
[merkleTree.toBuffer()],
BUBBLEGUM_PROGRAM_ID
);
const createTreeIx = createCreateTreeInstruction(
{
merkleTree,
treeAuthority,
treeCreator: payer,
payer,
logWrapper: SPL_NOOP_PROGRAM_ID,
compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
},
{
maxBufferSize: depthSizePair.maxBufferSize,
maxDepth: depthSizePair.maxDepth,
public: false,
},
BUBBLEGUM_PROGRAM_ID
);
const mintIx = createMintV1Instruction(
{
merkleTree,
treeAuthority,
treeDelegate: payer,
payer,
leafDelegate: payer,
leafOwner: payer,
compressionProgram: SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
logWrapper: SPL_NOOP_PROGRAM_ID,
},
{
message: compressedNFT,
}
);
const tx = new Transaction().add(allocTreeIx).add(createTreeIx).add(mintIx);
tx.feePayer = payer;
await sendAndConfirmTransaction(
connection,
tx,
[merkleTreeKeypair, payerKeypair],
{
commitment: "confirmed",
skipPreflight: true,
}
);
return {
merkleTree,
};
}