Guest User

Untitled

a guest
Nov 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. contract WithdrawalContract
  2.  
  3. state = { .richest : Address = 0,
  4. .mostSent : Uint = 0,
  5. .pendingWithdrawals : Map Address => Uint = [] }
  6.  
  7. fun becomeRichest() returns (Bool) =
  8. if (@call.value > @state.mostSent) then
  9. let totalAmount:Uint = pendingWithdrawals[@state.richest] + @call.value in
  10. {.state = @state[ .pendingWithdrawals = @state.pendingWithdrawals[@state.richest] = @call.value,
  11. .richest = @call.sender,
  12. .mostSent = @call.value],
  13. .return = true}
  14. else
  15. {.return = false}
  16.  
  17.  
  18. fun withdraw()
  19. let amount:Uint = @state.pendingWithdrawals[@call.sender] in
  20. { .state = @state[ @state.pendingWithdrawals[@call.sender] = 0],
  21. .transactions = spend_tx(amount, @call.sender)
  22. }
Add Comment
Please, Sign In to add comment