Storing SVGs onchain
Last updated
Last updated
Contracts deployed on Highlight automatically store all assets and metadata on Arweave. This is cheaper than storing data on the blockchain, while still guaranteeing decentralization.
In the case that you want all your data on your contract, this article will walk through how you can store SVGs and text on the blockchain.
Note: if you want to store files onchain, see Onchain File Storage.
To upload your SVG-based NFT onto your contract, you'll need to convert it into a Uniform Resource Identifier (URI) so that your browser can render it.
Once you have your URI for your token, you can write this directly onto your contract via the applicable block explorer (for instance, if your contract is deployed on Ethereum, you can use Etherscan).
Instructions below on how to write your SVG directly on your contract:
Deploy contract on Highlight
Go to block explorer, then "Write as Proxy". You’ll need to “verify as proxy” which can be done by selecting “more options”
Write to contract One of one, limited edition, or open edition For any of the above collection styles, to change an entire edition's metadata to SVG, go to field 22 "setEditionURI" Enter the editionID of the collection. This can be found on the token management page. For open editions, it will always be 0. Reference image below. For "_uri (string)", enter in the URI pointing to the token metadata. Generative or series style collection For series and generative series, you can update a single token's metadata to SVG. Use field 30 "setTokenURIs". Under "ids", enter in the token ID for applicable token. For URIs, enter in the URI for the token SVG.