Storing Pixel Art Data Directly on Ethereum Blockchain for NFTs

I’ve completed an art collection and want to save the actual image data on the blockchain instead of just links. I’m talking about something similar to what artists like deafbeef do with their work.

My project consists of 8x8 pixel images that come from source photos, so I can’t just generate them with code later. I think I need to somehow encode the raw pixel data and put it directly in the smart contract.

I’m pretty new to how blockchain technology works under the hood. I’ve created some NFTs on platforms like Foundation and SuperRare before, but I don’t really get what happens behind the scenes when you mint something.

Does anyone know good tutorials or guides that explain this process step by step? I’m looking for resources that show how to actually embed image data in contracts rather than just pointing to external files.

Any help would be great!

storage costs are brutal but honestly worth it for true ownership. ive been experimenting with base64 encoding for small images and its pretty efficent. you might wanna look into how cryptopunks stored thier data - they crammed all 10k into one contract somehow. also check out the artblocks contracts, they have some clever tricks for handling visual data onchain

Working with on-chain pixel art is definitely more complex than standard NFT minting but very rewarding. For 8x8 images, you’ll need to convert your pixel data into a format that can be stored efficiently in your smart contract - typically as hex values or compressed strings. I’ve done similar work with small pixel collections and found that storing the data as a mapping in your contract works well. Each pixel can be represented as RGB values, and you’ll want to implement a function that reconstructs the image data when requested. The gas costs can add up quickly though, so consider batching multiple images per transaction. Check out the ERC-721 extensions that support on-chain metadata. You’ll also want to look into SVG rendering directly in Solidity - this lets you output actual viewable images from your stored pixel data. The Loot project has some good examples of generating visual content entirely on-chain that might give you implementation ideas.

oh wow this sounds like a really cool project! i’m curious about your workflow - are you planning to convert those source photos into 8x8 manually or do you have some kind of script that downsamples them?

the gas costs for storing pixel data directly are gonna be pretty intense, even for tiny 8x8 images. have you thought about maybe doing a test mint first with just one piece to see what you’re looking at cost-wise? i remember reading somewhere that each byte of storage costs around 20k gas, so even a small image could get expensive quick.

what made you choose 8x8 specifically? i’m wondering if there’s a sweet spot between image quality and storage costs that works for your artistic vision. also are you thinking about storing them as raw RGB values or maybe using some kind of palette system to compress things down?

deafbeef’s stuff is incredible btw - their approach to generative on-chain art is so elegant. are you going for something similar where the contract can reconstruct the full image, or more like a direct pixel-by-pixel storage approach?

sorry for all the questions but this kind of project really fascinates me! the intersection of technical constraints and artistic expression in blockchain art is just so interesting to explore.