-
Notifications
You must be signed in to change notification settings - Fork 7
Description
I think we can make SRC721 extendable to web apps and rich generative experiences if we make some slight modification to the structure of the src721.
The deploy op has a
"type": "data:image/png;base64",// mime type of the images used in traits t0-tx
When i first did this i assumed that the type would be the same and that it would be used in the creation of an SVG filled with images. This works well when you're trying to stack a bunch of images but doesn't really allow for more feature rich content.
I think we should create a special mimetype like
"type":"src721:text/html", // special mime type for building HTML from chunks
This mimetype would signify that all traits t0-tx are either
- Javascript
- CSS
- HTML (fragment)
Note: HTML content should be presented in an iframe in a sandboxed environment to ensure no outside scripts are run. The only exception to outside references should be to cp assets with the destination /asset/{xcp asset id}
Storing any file in a stamp
Even though they wont be indexed by the current indexer,
Files will be uploaded with the stamp prefix, then their name followed by the data.
In this example, the files are gzipped the base64 encoded. For javascript libraries, gz compression averages 77%. when accounting for the 1/3 increase in b64 encoding, we can still get a ~71% size reduction
stamp:filename.js.gz.b64;H4sIAOv1nmQAA...
For files larger than 6kb, it will be necessary to allow these stamps to point at other stamps. This is easily achievable by adding a pointer to another asset after the filename. This allows us to store files of any size in 6kb chunks. Obviously the costs would be very large so it would be desirable to keep these files as small as possible.
stamp:filename.js.gz.b64,A12345678;H4sIAOv1nmQAA...
Creating the gzipped then base64 encoded file is easy, we just need to output the file and pipe it into the libraries gzip then base64.
cat filename.js | gzip | base64
Note: If anyone says these aren't fully on chain because the tools to decode/inflate arent on chain, we can easily upload the libraries for inflating, b64 decoding and mime checking so that everything is on chain... it will only be a few kb. it's kind of a silly argument though...
Referencing files in SRC721
So with this format a user can store any file on chain. When interpreting an SRC721 of "type":"src721:text/html" Each traits t0-tx would be added to the DOM of a bare html file in the body section in order. With this structure we can compose any html document. This is very similar to what Scripty.sol is doing on ethereum and also has some similarities to what we did with LNR Web
Additionally we should have an optional property in the mint op d:{b:"", t0:"", tx:""} where we can store general purpose data that will will be put inside of script tags before (b) or after each dom item.