Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
Recurring Error on NFT Art generator script, index.js: DNA Exists

I can't find line where DNA is called, before I added some lines of code the code was executing just fine. Now the error is running and won't let me quit the execution.

Here is the line where Dna is created on index.js. I see it calls for variable races and race but I don't know how races makes the dna

    const createDna = (_races, _race) => {
      let randNum = [];
      _races[_race].layers.forEach((layer) => {
        let randElementNum = Math.floor(Math.random() * 100) + 1;
        let num = 0;
        layer.elements.forEach((element) => {
          if (randElementNum >= 100 - element.weight) {
            num = element.id;
          }
    });
        randNum.push(num);
      });
      return randNum;
    };

Then, in config.js the variable _races appears here. I don't know if what follows from the rest of the code is important for your answer, but this is what I've got so far...

const fs = require("fs");
const width = 708;
const height = 1080;
const dir = __dirname;
const description = "This is an NFT made by the coolest generative code.";
const baseImageUri = "https://hashlips/nft";
const startEditionFrom = 1;
const endEditionAt = 34;
const editionSize = 34;
const raceWeights = [
  {
    value: "skull",
    from: 1,
    to: editionSize,
  },
];

const races = {
  skull: {
    name: "skull",
    layers: [
      {
        name: "Background",
        elements: [
          {
            id: 0,
            name: "Light pink",
            path: `${dir}/1-background/PRDE_0008s_0000_Capa-5.png`,
            weight: 100,
          },
]
         // etc...
]

}

When I break the execution, the process exits with this message

Uncaught TypeError: Cannot read properties of undefined (reading 'layers')

and it only produces 24 layers of pngs out of the total 34 I asked it to produce. What's wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!