ETHTornado.sol 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // SPDX-License-Identifier: MIT
  12. pragma solidity ^0.7.0;
  13. import "./Tornado.sol";
  14. contract ETHTornado is Tornado {
  15. constructor(
  16. IVerifier _verifier,
  17. IHasher _hasher,
  18. uint256 _denomination,
  19. uint32 _merkleTreeHeight
  20. ) Tornado(_verifier, _hasher, _denomination, _merkleTreeHeight) {}
  21. function _processDeposit() internal override {
  22. require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
  23. }
  24. function _processWithdraw(
  25. address payable _recipient,
  26. address payable _relayer,
  27. uint256 _fee,
  28. uint256 _refund
  29. ) internal override {
  30. // sanity checks
  31. require(msg.value == 0, "Message value is supposed to be zero for ETH instance");
  32. require(_refund == 0, "Refund value is supposed to be zero for ETH instance");
  33. (bool success, ) = _recipient.call{ value: denomination - _fee }("");
  34. require(success, "payment to _recipient did not go thru");
  35. if (_fee > 0) {
  36. (success, ) = _relayer.call{ value: _fee }("");
  37. require(success, "payment to _relayer did not go thru");
  38. }
  39. }
  40. }