GoodPullPayments.sol 511 B

123456789101112131415161718192021222324
  1. contract GoodPullPayments {
  2. address highestBidder;
  3. uint highestBid;
  4. mapping(address => uint) refunds;
  5. function bid() external {
  6. if (msg.value < highestBid) throw;
  7. if (highestBidder != 0) {
  8. refunds[highestBidder] += highestBid;
  9. }
  10. highestBidder = msg.sender;
  11. highestBid = msg.value;
  12. }
  13. function withdrawBid() external {
  14. uint refund = refunds[msg.sender];
  15. refunds[msg.sender] = 0;
  16. if (!msg.sender.send(refund)) {
  17. refunds[msg.sender] = refund;
  18. }
  19. }
  20. }