GoodPullPayments.sol 535 B

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