Storing Data On-Chain
Right click, save on Ethereum
Last updated
Right click, save on Ethereum
Last updated
As you may know from our previous tutorials, Manifold Studio stores all metadata and assets related to your NFT on Arweave. This is a cheaper solution than storing all this data on the Ethereum blockchain itself, while still maintaining decentralization -- ensuring your assets can never be taken down.
In any case, you may still want to store all data related to your NFT on-chain, if for instance you are dealing with a small SVG or a piece of text and really want to be inside your contract on the blockchain itself!
In this tutorial we will learn how to do this by leveraging your Manifold Creator contract, a few open-source tools, and Etherescan!
For this tutorial we will create an NFT with the title "Seed Phrase" and description "Never share it" from the following SVG:
Feel free to follow along using any valid SVG of your choosing.
Now that we have our SVG we will transform it into a Data URI so that our browser can render it like any other URL.
We must make our SVG more compact and then convert it into a Data URI by using this tool.
Copy your SVG into the editor
Click "Optimize" in the bottom of the editor page.
Go the Data URI
tab and copy the Minified Data URI
option.
Huzzah you have done it! You should now have a Data URI representing your SVG that looks something like this:
Save this URL, we'll need it in Step 2.
As a sanity check: Paste it into your browser's URL bar then visit the URL. You should see the SVG render on screen.
Now that we have our SVG as a Data URI, we next need to create our JSON object representing the NFT's metadata and turn that into a Data URI too.
This metadata object specifies things such as the name, description, and of course, the image of the NFT! You can learn more about what else is allowed inside this JSON object by referencing the OpenSea Metadata Standards Document
We suggest you start by defining your metadata as a JSON object with just three fields like so:
Remember to swap in the string we generated from Step 2 into the image
field, like so for our running example:
Once your metadata looks good, copy and paste the entirety of your JSON into our handy-dandy tool which will compress it, and then turn it into a JSON Data URI for you. If there are any errors in your JSON our little app will throw errors. If that is the case, head to the JSON Validator and fix your issues first, then try again.
Copy it to your clipboard, and save it somewhere, as we'll need it for minting in Step 4.
For our running example, the final output looks like so:
Now that we have our metadata with our SVG inside of it converted into a single URI, we can go ahead and mint our NFT on Etherscan.
For this example we will mint our NFT on Sepolia, so make sure the contract you are using is a draft contract that has been deployed to the Test Network.
Head over to your draft contract on Manifold Studio and click on its address. This will open Sepolia Etherscan for you.
Open the "Contract" tab and click on "Write as Proxy" bellow.
Click on Connect to Web3
and connect using the wallet that is owner of your contract.
Head over to the mintBase
function. There will be two, open the one with two fields to (address)
and uri (string)
Fill the to (address)
field with the address where you want the NFT to be on, for our example we'll use some address. Then, fill the uri (string)
field with the encoded string we generated at the very end of Step 3.
Once you are ready, you can then mint the NFT by clicking on the Write
button and executing the transaction from your wallet.
To double check your token on OpenSea go to the following URL:
To find the values of your Sepolia contract address and the token number you minted you can click on View your transaction"
buttoninside Etherscan that appears once your transaction is submitted:
Inside that page you'll see your contract with a green check mark and the token number bellow where it says ERC-721 TokenID[<MINTED_TOKEN>]
, in my case it's token number 5
. This might take a few seconds to appear.
So for me, I'll find my token by going to this URL:
Where 0xc1d87f2c5fa21ce0cec0cd711f2cfd65e0d0eb6e
is my contract address and 5 is my token number.
OpenSea might take some time to process the NFT metadata so if you are seeing just a placeholder image, wait a few minutes and refresh the metadata by clicking on the circular arrow on the top right:
And there you go!
You've minted your SVG and all of its metadata entirely on the Ethereum blockchain, no dependencies!
To do this on Mainnet follow the exact same steps but instead of using a Test Network Creator Contract use your Creator Contract that lives on Mainnet!