Live data from Hacker News

Show HN: /r/place backed by the Bitcoin blockchain

mess110.github.io

21–29 of 29 posts

Re: Show HN: /r/place backed by the Bitcoin blockchain

#21

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 colorPi…

> msg.sender.send(p.lastPayment); // refund previous price of pixel

This code suffers from Recursive calling vulnerability (same bug which caused the DAO to be hacked).

You're sending the money BEFORE you're updating the balances.

There is a better way to write the payment code (and also wouldn't take you more than 5 minutes to write).

Here is one way to do it:

    function colorPixel(uint x, uint y, bytes3 color) payable onBoard(x, y) { 
      Pixel p = board[x][y];
      lastPayment = p.lastPayment;
      p.lastPayment = msg.value;
      if (msg.value > lastPayment) {
        if(!msg.sender.send(lastPayment)) throw; // refund previous price of pixel
        p.color = color;                // set the color
      } else {
        throw;
      }
    }
Another shorter way:

    function colorPixel(uint x, uint y, bytes3 color) payable onBoard(x, y) { 
      Pixel p = board[x][y];
      require(msg.value > p.lastPayment);
      if(!msg.sender.send(p.lastPayment)) throw; // refund previous price of pixel
      p.color = color;                // set the color
      p.lastPayment = msg.value;      // set new cost to whatever the person sent in
    }

Re: Show HN: /r/place backed by the Bitcoin blockchain

#22

Earlier quoted context omitted.

Agreed. I think it could be a great way to raise money for some kind of cause though.

> I think it could be a great way to raise money for some kind of cause though. I'd like to see some proof that the charity-runner isn't going to abscond with the money once it was done, either due to maliciousness, or even something like getting stressed out over success (like some Kickstarters have done.) (And yeah, I know - it's not like it's a Bitcoin/blockchain only problem - but at least with "real" money, ther…

Another user suggested using Ethereum smart contracts for this. I'm not terribly familiar with Ethereum, but I wonder if the contract could be designed to automatically forward to a Charity-held wallet, or even the wallet of a reputable intermediary like Watsi.

Re: Show HN: /r/place backed by the Bitcoin blockchain

#23

Earlier quoted context omitted.

> I think it could be a great way to raise money for some kind of cause though. I'd like to see some proof that the charity-runner isn't going to abscond with the money once it was done, either due to maliciousness, or even something like getting stressed out over success (like some Kickstarters have done.) (And yeah, I know - it's not like it's a Bitcoin/blockchain only problem - but at least with "real" money, ther…

Another user suggested using Ethereum smart contracts for this. I'm not terribly familiar with Ethereum, but I wonder if the contract could be designed to automatically forward to a Charity-held wallet, or even the wallet of a reputable intermediary like Watsi.

I'd be incredibly wary of using Ethereum contracts for this. The DAO has shown that writing software is apparently difficult.

Re: Show HN: /r/place backed by the Bitcoin blockchain

#24

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 colorPi…

> msg.sender.send(p.lastPayment); // refund previous price of pixel This code suffers from Recursive calling vulnerability (same bug which caused the DAO to be hacked). You're sending the money BEFORE you're updating the balances. There is a better way to write the payment code (and also wouldn't take you more than 5 minutes to write). Here is one way to do it: function colorPixel(uint x, uint y, bytes3 color) payabl…

Good analysis of the code, and nice correction. Agreed that you should always check your sends' return values, too! In this example you have to send more than the last guy, so I think a recursive call would still put in more ether than would be withdrawn. Still undesired though.

If it were fleshed out more it should probably return the ether to the last depositor instead of the purchaser.

Thanks for the feedback!; I'm tempted to turn this into an example Dapp later today.

Re: Show HN: /r/place backed by the Bitcoin blockchain

#25

Earlier quoted context omitted.

> I think it could be a great way to raise money for some kind of cause though. I'd like to see some proof that the charity-runner isn't going to abscond with the money once it was done, either due to maliciousness, or even something like getting stressed out over success (like some Kickstarters have done.) (And yeah, I know - it's not like it's a Bitcoin/blockchain only problem - but at least with "real" money, ther…

Another user suggested using Ethereum smart contracts for this. I'm not terribly familiar with Ethereum, but I wonder if the contract could be designed to automatically forward to a Charity-held wallet, or even the wallet of a reputable intermediary like Watsi.

You can accomplish the same with the OP's Bitcoin implementation just by having the charity own all of the Bitcoin addresses used.

Re: Show HN: /r/place backed by the Bitcoin blockchain

#26

Earlier quoted context omitted.

Another user suggested using Ethereum smart contracts for this. I'm not terribly familiar with Ethereum, but I wonder if the contract could be designed to automatically forward to a Charity-held wallet, or even the wallet of a reputable intermediary like Watsi.

I'd be incredibly wary of using Ethereum contracts for this. The DAO has shown that writing software is apparently difficult.

What do you think about Tezos Smart Contracts then?

Re: Show HN: /r/place backed by the Bitcoin blockchain

#27

Earlier quoted context omitted.

I'd be incredibly wary of using Ethereum contracts for this. The DAO has shown that writing software is apparently difficult.

What do you think about Tezos Smart Contracts then?

I've done no research, I don't really know much about the whole... ledgersphere?

Seems like it just puts in a mechanism for changing the protocol without forking the chain, but I'm not sure why people couldn't continue running the old protocol, effectively forking it anyway (other than a "look, we all agreed to no forks, you're explicitly a dick if you fork it, not just someone with a disagreement" angle.)

Re: Show HN: /r/place backed by the Bitcoin blockchain

#28

Earlier quoted context omitted.

What do you think about Tezos Smart Contracts then?

I've done no research, I don't really know much about the whole... ledgersphere? Seems like it just puts in a mechanism for changing the protocol without forking the chain, but I'm not sure why people couldn't continue running the old protocol, effectively forking it anyway (other than a "look, we all agreed to no forks, you're explicitly a dick if you fork it, not just someone with a disagreement" angle.)

Oh well I was pointing out to the part where their whole codebase is formally prove, plus their Smart Contract language Michelson is functional and can be used very easily to be formally proven (there by leading to writing more secure smart contracts), since you're earlier concern was security.

Re: Show HN: /r/place backed by the Bitcoin blockchain

#29

Earlier quoted context omitted.

I've done no research, I don't really know much about the whole... ledgersphere? Seems like it just puts in a mechanism for changing the protocol without forking the chain, but I'm not sure why people couldn't continue running the old protocol, effectively forking it anyway (other than a "look, we all agreed to no forks, you're explicitly a dick if you fork it, not just someone with a disagreement" angle.)

Oh well I was pointing out to the part where their whole codebase is formally prove, plus their Smart Contract language Michelson is functional and can be used very easily to be formally proven (there by leading to writing more secure smart contracts), since you're earlier concern was security.

I don't see that anywhere, although I only googled very briefly. The closest I saw was this:

> Updates to the protocol can be required to carry formal proofs indicating that they respect agreed core principles agreed upon by the stakeholders.

Which doesn't really make sense; how do you write a formal proof that something align with someone's core principles?

Post reply on HN