Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign URIs randomly within a range #1

Open
sagaratalatti opened this issue Mar 9, 2023 · 0 comments
Open

Assign URIs randomly within a range #1

sagaratalatti opened this issue Mar 9, 2023 · 0 comments

Comments

@sagaratalatti
Copy link
Owner

const collectionUriPrefixes = new Set();
while (collectionUriPrefixes.size < 6) {
  collectionUriPrefixes.add(Math.floor(Math.random() * 3000) + 1);
}

// Convert set to array and assign as environment variables
const envPrefixes = [...collectionUriPrefixes].map((num, index) => `COLLECTION_URI_PREFIX_${index + 1}=${num}`);
for (const envPrefix of envPrefixes) {
  process.env[envPrefix.split('=')[0]] = envPrefix.split('=')[1];
}

// Attach to deployed contract
const contract = await NftContractProvider.getContract();

// Update root hash (if changed)
for (let i = 1; i <= 6; i++) {
  const envVarName = `COLLECTION_URI_PREFIX_${i}`;
  const envVarValue = process.env[envVarName];
  if ((await contract.uriPrefix(i)) !== envVarValue) {
    console.log(`Updating URI prefix ${i} to: ${envVarValue}`);
    await (await contract.setUriPrefix(i, envVarValue)).wait();
  }
}```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant