This video is available to students only

Million Ether Page Essential Smart Contract

Let's build the essential contract for the Million Ether page. First, let's make a place for it.

We're going to be storing our pixels in a 1000x1000 grid. The zero-zero point is the top left with x increasing to the right, and y increasing towards the bottom.


Remember that we're storing each pixel as 3 bytes. The datatype for this in Solidity is bytes3. In our contract, we'll represent this grid, initially, as a two dimensional array of bytes3.

This array is going to be stored in our contract's storage. That is, every node on the Ethereum network will hold a copy of these pixels.

We'll mark these pixels public which means that Solidity will automatically create a public getter function to read these values.

colorPixel#

To set a pixel color, we'll use the function colorPixel - it accepts an unsigned integer for the x and y location and a bytes3 for the color.

When this function is called, it will update the pixel at the appropriate location.

This contract is simple. We're storing a million pixels in our contract, with no restriction. This is just the first version. Over the next few videos we're going to talk about how bid for and buy pixels, how to emit events when pixels change, and how to give refunds when someone is outbid.

While those ideas might sound simple, there are a lot of tricky details that we're going to work through along the way.

 

This page is a preview of Million Ether Homepage

Start a new discussion. All notification go to the author.