Information how to make deterministic randomness easily in js Any more question? Join our discord http://chat.beyondnft.io
"Seeding" is a way to initialize a piece, so every time it is rendered, it always follow the same sequence in its "randomization"
When creating something generative, one usually use "random()" a lot.
When you create "deterministic generative", you want these "random" calls to always follow the same sequence, for a given context
This is where "seeding" comes into play, allowing to always have the same sequence when you use random(), creating "deterministic randomness" ⇒ Each piece is unique, but every time the piece is rendered, it's rendered the same way as the previous time
Examples:
1) random without seeding:
you run the script a first time
random() returns 0.0003 random() returns 0.1 random() returns 0.7
you leave the page. then you come back which runs the script a second time
random() returns 0.04 random() returns 0.8 random() returns 0.3
totally different outputs
2) random with seeding:
you run the script a first time
-> the script "seeds" random randomSeed(123456);
random() returns 0.03 random() returns 0.15 random() returns 0.78
you leave the page. then you come back which runs the script a second time
-> the script "seeds" random randomSeed(123456);
random() returns 0.03 random() returns 0.15 random() returns 0.78
in this case, everytime you come back, the sequence will always be the same
owner
, viewer
or seed
On BeyondNFT, we pass values to the code that can be used to seed the deterministic rendering.
On normal NFTs, you can use either the owner
or the viewer
query parameters passed to the iframe.
On NFTs issued from factories of type Random seed
or Input seed
you can also use different parameters that are added to the NFT JSON like for exemple seed
, available in the code using:
beyondHelpers.get('seed')
or in the JSON Metadata $factoryData.seed
property