You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Attach to deployed contract
const contract = await NftContractProvider.getContract();
// Define the 6 different URIs and their assigned ranges
const uris = [
{ uri: process.env.COLLECTION_URI_PREFIX_1, range: [1, 500] },
{ uri: process.env.COLLECTION_URI_PREFIX_2, range: [501, 1000] },
{ uri: process.env.COLLECTION_URI_PREFIX_3, range: [1001, 1500] },
{ uri: process.env.COLLECTION_URI_PREFIX_4, range: [1501, 2000] },
{ uri: process.env.COLLECTION_URI_PREFIX_5, range: [2001, 2500] },
{ uri: process.env.COLLECTION_URI_PREFIX_6, range: [2501, 3000] },
];
// Shuffle the array of NFT IDs
const nftIds = Array.from({ length: 3000 }, (_, i) => i + 1);
for (let i = nftIds.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[nftIds[i], nftIds[j]] = [nftIds[j], nftIds[i]];
}
// Assign the URIs to the NFTs based on the predefined ranges
for (const { uri, range } of uris) {
const [start, end] = range;
for (let i = start; i <= end; i++) {
const nftId = nftIds[i - 1]; // NFT IDs are 1-indexed
console.log(`Assigning URI ${uri} to NFT ${nftId}`);
await (await contract.setTokenURI(nftId, uri)).wait();
}
}
The uris array is an array of objects, where each object has a uri property that specifies the URI, and a range property that specifies the range of NFT IDs that should be assigned to that URI. The nftIds array is shuffled using the Fisher-Yates algorithm, as before. The code then loops through each URI and assigns the URI to the NFTs whose IDs fall within the predefined range for that URI.
The text was updated successfully, but these errors were encountered:
The uris array is an array of objects, where each object has a uri property that specifies the URI, and a range property that specifies the range of NFT IDs that should be assigned to that URI. The nftIds array is shuffled using the Fisher-Yates algorithm, as before. The code then loops through each URI and assigns the URI to the NFTs whose IDs fall within the predefined range for that URI.
The text was updated successfully, but these errors were encountered: