Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

336
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda