Tiles, Hex Triplets, Gas Prices and the Compression Contest

Ken Erwin
3 min readSep 10, 2021

--

A Mario Star

In November of 2016, I launched pixelmap.io, one of the world’s earliest NFTs (preceded by etheria.world, which is incredible and launched an entire year earlier!).

I was heavily inspired by Alex Tew’s Million Dollar Homepage https://en.wikipedia.org/wiki/The_Million_Dollar_Homepage, where each pixel was sold for a (US) dollar. However, when people bought the pixels, they had two limitations. One, they weren’t truly owned by individuals, as it was up to the owner of the website to put them up. Additionally, if the site was ever taken down or DDoS’d, the pixels would cease to exist.

In 2016, I started learning Solidity and decided to make a decentralized version. By storing each tile on the blockchain — once a tile is sold, they truly are 100 percent owned by the purchaser. At any time, they can change the URL the tile links to, as well as the image. The images themselves though are essentially invincible, including all history of each tile, provided even a single Ethereum node remains running somewhere in the world. The only thing that can be altered is the frontend that displays them, but even that has been open-sourced so that anyone can easily spin it up even locally to view the tiles.

Now, in order to do all of that, I needed a way to efficiently store the tile data. I’ve documented the format here, https://github.com/Pixel-Map/pixelmap.io, but the TLDR is, each tile is a 768 character set of hex triplets, each representing a single pixel as a websafe color. In 2016, gas prices for Ethereum were so low that it was relatively inexpensive to set the image. As of today (September 10th, 2021), depending on the time of day, it can range from $100 to $500 or more for a single tile.

I have no interest in changing the way that PixelMap works — because a huge part of it is how immutable everything is when done as a smart contract. The one thing I think we can do though is to make it so that if someone uses a more efficient process to store the data (using the same image field, as it’s stored as a string), we can make it so that people can update their tile at a much lower price, while still maintaining all of the images directly on the chain.

I’ve heard from several people that we could look at using some form of compression, or a palette map. I’ve also looked into the RLE methods that were used for the NES and SNES, but it is definitely not my strength. So that is the reason for this post.

I would like to start a competition, ending at midnight EST, at the end of this month (September). Whoever is able to come up with the best compression (using NodeJS as I don’t want to rewrite it :D), will be given a free tile (at the current time, that’s roughly 2 Eth give or take, so ~$8k USD, depending on fluctuations on OpenSea, Ethereum price, etc.)

We’ll also use that tile as the first one to use the new compression method. And provided you don’t want to be anonymous, I’d love to interview you as well if you’re the winner :).

Here’s the rules:

  • Must support all web safe colors https://htmlcolorcodes.com/color-chart/web-safe-color-chart/
  • Must store 16x16 pixels (that is the size of a single tile)
  • Must be lossless
  • Should be optimized to save as much Eth gas as possible
  • Will be tested with a range of tiles, some containing just a few colors, and some containing a wide variety of colors. I’ll publish the list of test images soon, and we’ll use the average length of the string that the algorithm uses to determine the winner.

If you’d like to enter the contest, create it within a Github repo or Gist, and tweet it to me at kenerwin88, or you can also let us know on the PixelMap discord. Good luck!

Ken

--

--

No responses yet