
Saved by Darren LI
Why Art Blocks Uses JavaScript in Its Smart Contract
Saved by Darren LI
Why is the image not generated/rendered on-chain? It’s because the scripts have library dependencies. The scripts depend on common JavaScript libraries such as p5.js and processing which are commonly used by designers to create generative images. It would be very expensive to put these dependency libraries on-chain and that’
... See moreSo, what do you really own when you buy an NFT? In this case, you just own the tokenId . tokenUri function then maps the tokenId to either IPFS or HTTP link depending on the project settings. This link either points to the image directly or to a JSON that has attributes and a nested link to the image.
But how is the image generated/rendered? Unfortunately, the image is not generated on-chain. The smart contract only stores a JavaScript script needed to render the image. Art Blocks’ frontend then queries this script and generates the image on-demand in its traditional backend, not the blockchain backend.