Skip to content

Seed handling: regenerate_token stores raw bytes in artifactUri (invalid JS/UTF-8); stored artifact seed differs from frontend render seed #30

Description

@TheBenMeadows

Hi — I published generator svg-js/407 ("essentialism") today and found two seed-handling issues while verifying my token's on-chain data. They are related but have different fixes, so both are here.

1. regenerate_token writes raw entropy bytes into the stored artifactUri

Token 5364 was minted, then regenerated after a generator update. Its token_metadata artifactUri now contains the seed as 32 raw bytes spliced directly into the JavaScript:

...CDATA%5Bconst%20SEED%3D<32 raw bytes: e9 fa 85 15 ca f8 23 a1 ...>n%3Bfunction%20splitmix64...

The bytes match token_extra.seed for that token exactly. As stored, the artifact is not valid UTF-8 (the URI declares utf8) and not valid JavaScript, so it cannot execute if rendered directly from chain. A token that was never regenerated (5360, from a different generator) has a decimal number in the same position and executes fine. It looks like the mint path converts the seed to a decimal string and the regenerate path splices the raw bytes.

Repro: pull token_metadata for KT1CB4MYiAViCuXWBU961x7LjQXGeA8SnQwt tokens 5364 and 5360 from TzKT, hex-decode artifactUri, and inspect the bytes after SEED%3D.

2. Stored artifact seed and frontend render seed disagree

GeneratorDetail.jsx derives the display seed as Number(entropyBigInt % BigInt(2**32)). The stored artifact embeds a different, longer decimal. Measured on token 5360:

  • entropy (token_extra.seed): 0x18478c30bb481ebf1a6ee178...
  • frontend render seed (entropy mod 2^32): 238430315
  • seed in the stored artifact: 11255154335010276574979107168794546114640444480930463, which splitmix64's 64-bit mask reduces to 295956255023153823

Those two values produce different rnd streams, so the artwork inside the stored artifact and the artwork the site renders are different images for the same token. I confirmed on my own token that the site render corresponds to entropy mod 2^32.

If the stored artifact is meant to be canonical, the renderer could parse the seed out of the artifact; if the frontend derivation is canonical, the artifact assembly could embed that value. Either way they should agree.

Happy to share the verification scripts and side-by-side renders for both issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions