Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

327
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda