ETHTornado.sol 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // https://tornado.cash
  2. /*
  3. * d888888P dP a88888b. dP
  4. * 88 88 d8' `88 88
  5. * 88 .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b. 88 .d8888b. .d8888b. 88d888b.
  6. * 88 88' `88 88' `88 88' `88 88' `88 88' `88 88' `88 88 88' `88 Y8ooooo. 88' `88
  7. * 88 88. .88 88 88 88 88. .88 88. .88 88. .88 dP Y8. .88 88. .88 88 88 88
  8. * dP `88888P' dP dP dP `88888P8 `88888P8 `88888P' 88 Y88888P' `88888P8 `88888P' dP dP
  9. * ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
  10. */
  11. pragma solidity ^0.5.8;
  12. import "./Tornado.sol";
  13. contract ETHTornado is Tornado {
  14. constructor(
  15. IVerifier _verifier,
  16. uint256 _denomination,
  17. uint32 _merkleTreeHeight,
  18. address _operator
  19. ) Tornado(_verifier, _denomination, _merkleTreeHeight, _operator) public {
  20. }
  21. function _processDeposit() internal {
  22. require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
  23. }
  24. function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal {
  25. // sanity checks
  26. require(msg.value == 0, "Message value is supposed to be zero for ETH instance");
  27. require(_refund == 0, "Refund value is supposed to be zero for ETH instance");
  28. (bool success, ) = _recipient.call.value(denomination - _fee)("");
  29. require(success, "payment to _recipient did not go thru");
  30. if (_fee > 0) {
  31. (success, ) = _relayer.call.value(_fee)("");
  32. require(success, "payment to _relayer did not go thru");
  33. }
  34. }
  35. }