Comment

Comment by scientaster

Would have been much easier with an ethereum smart contract. No gimmicky address list, it's a crowdsourced picture in the blockchain.

  contract Place {
    struct Pixel {
      bytes3 color;
      uint lastPayment;
    }

    Pixel[10000][10000] board;

    modifier onBoard(uint x, uint y) {
      if (x > 10000 || y > 10000) {
        throw;
      } 
      _;
    }

    // Accepts funds, if the funds sent are greater than funds for that pixel last, change the color.
    function colorPixel(uint x, uint y, bytes3 color) payable onBoard(x, y) { 
      Pixel p = board[x][y];
      if (msg.value > p.lastPayment) {
        msg.sender.send(p.lastPayment); // refund previous price of pixel
        p.color = color;                // set the color
        p.lastPayment = msg.value;      // set new cost to whatever the person sent in
      } else {
        throw;
      }
    }
  }
May contain an error or two, but that's the general gist of it.
parent scientaster 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton