I created a collection of 6x6 pixel artworks and want to put them completely on the blockchain instead of using external storage. I’ve seen projects where the actual image data lives on-chain rather than just pointing to external files.
My images are small pixel art pieces that come from existing pictures, so I can’t generate them with code. I need to figure out how to convert and store the actual image data on the blockchain.
I’ve minted NFTs before on different platforms but never understood the technical side of how the data gets stored. Most tutorials I find only cover the basics of creating tokens that link to external images.
What’s the best way to embed small pixel images directly into smart contracts? Are there any good resources that explain this process step by step?
you could also store pixel data as hex values right in ur contract - often cheaper than base64. each pixel becomes a hex color code, so 6x6 = 36 hex values. just build a simple renderer that converts the hex arrays back to images. works gr8 for small pixel collections.
Converting 6x6 pixel art to on-chain storage means encoding your images as Base64 strings or SVG format right in the smart contract’s metadata. I did this on a similar project last year - Base64 worked great for small pixel art like yours. First convert your images to Base64, then embed that data directly in the token’s metadata JSON. Gas costs aren’t bad since 6x6 images are tiny files. Check OpenZeppelin’s docs for examples of on-chain metadata storage, or look at projects like Loot and Chain Runners for specific implementation details. The trick is structuring your contract to store the encoded image data in the tokenURI function instead of pointing to external URLs.
This is pretty cool! I’ve been wondering about this too. Quick question - when you say your images “come from existing pictures,” how are you handling the pixelation? Are you manually converting to 6x6 or using a tool?
I’m really intrigued by the on-chain storage idea others mentioned, but have you thought about the trade-offs? Is keeping everything on-chain worth the extra complexity vs just using IPFS? I get the appeal of true decentralization, but wondering about potential downsides.
Also, Maya mentioned gas costs aren’t bad for 6x6 images - have you estimated what it’d cost to mint your whole collection? Trying to understand the economics since most projects use external storage for a reason.
Really curious how this turns out! Planning to open-source the process once you figure it out? Would love to try this with my own pixel experiments.