Skip to content

A smart contract to power a dynamic pixel grid

Notifications You must be signed in to change notification settings

prism0x/smart-contract

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ethereum Pixels Smart Contract

This is the smart contract that powers the backend logic of Ethereum Pixels, an interactive 1000x1000 grid that allows Ethereum users to own and maintain Pixels. It runs on the main Ethereum blockchain and was partly inspired by Reddit's r/place.

Contract Features

  • Mapping of one million Pixels containing ownership, price and color information
  • Mapping of Ethereum addresses to stored balance and a personalized message that is displayed on all Pixels owned by the address
  • Any Ethereum account may purchase Pixels by interacting with the API
  • Current owner of a Pixel is paid when the Pixel is purchased by another account
  • Stored balance and payments using the withdrawal pattern
  • Automatic refunds on a failed purchase due to invalid coordinates or unmet price
  • Automatic price increment logic when a Pixel changes ownership
  • Small maintenance fee levied for each successful purchase

Color Format

The Pixel colors are stored as 24-bit unsigned integers that mostly correspond to a typical web color palette. For example, #ff0000 (red) is stored as 16711680. The only exception is that 0, which is also the value returned by Solidity for uninitialized memory, is rendered on the front end as transparent instead of #000000 (black).

Important Methods

  • buyPixel(uint16 row, uint16 col, uint24 newColor)
  • getPixelColor(uint16 row, uint16 col)
  • getPixelPrice(uint16 row, uint16 col)
  • checkPendingWithdrawal()
  • withdraw()

About

A smart contract to power a dynamic pixel grid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%