ETH Price: $1,971.29 (+0.13%)

Transaction Decoder

Block:
12100123 at Mar-24-2021 06:59:13 AM +UTC
Transaction Fee:
0.04335456 ETH $85.46
Gas Used:
361,288 Gas / 120 Gwei

Emitted Events:

2 TetherToken.Transfer( from=[Receiver] TornadoCash_erc20, to=0x458219485Fd43D9e62ddE453f854cede0afB5913, value=882548060 )
3 TetherToken.Transfer( from=[Receiver] TornadoCash_erc20, to=0x0b97Abcab8675c425668863dA906c41DE4595882, value=117451940 )
4 TornadoCash_erc20.Withdrawal( to=0x458219485Fd43D9e62ddE453f854cede0afB5913, nullifierHash=2755961993C9C6A79B2C65B1CCE8B0AD81072042664969247C9253BFFDCC3317, relayer=0x0b97Abcab8675c425668863dA906c41DE4595882, fee=117451940 )

Account State Difference:

  Address   Before After State Difference Code
0x0836222F...38D1a872f
(Tornado.Cash: 1,000 USDT)
0x3f6eA4A3...355b4Df5D
7.897694886702049927 Eth
Nonce: 1315
7.834340326702049927 Eth
Nonce: 1316
0.06335456
0x45821948...e0afB5913 1.712762627269432 Eth1.732762627269432 Eth0.02
(F2Pool Old)
4,809.464871026613147644 Eth4,809.508225586613147644 Eth0.04335456
0xdAC17F95...13D831ec7

Execution Trace

ETH 0.02 TornadoCash_erc20.withdraw( _proof=0x1FEF890101B46EAEE8228366A86776BF64D810BD3AE43B44F9E54C47B61AA36B1CB0EDD280F45A4CC1D2F3C5CDE5CF143711B49D2340995FCA14C808A922F1091C469B84881FC39B07BF6C0B8677CCF2CB0E2944421FC64652424F754FEA3255025F31A216D1E7A7ED96903494EE203B8963AD794D36A5099229A3AE740FBAE91CD88DC69B57B6D1F31016A9428957DA180C287276FEB26B818941678FC5C875115D4F7193AAA5DC58737CF1AA77A74E1BEF1F151A845EBCDB9EFE29D95570E527EBFE96537DB36098290AAA4C1A260C1D9A55C171831BBA786C44FB76DAEF7713EE83734EB8E97CFBD1349CAB0800F535A07A1938694715E208B65FA3503BF0, _root=10BD63416C007E5763BBF1A60BFC0093B8F4CDEACB4925ACDB98DE15735283F5, _nullifierHash=2755961993C9C6A79B2C65B1CCE8B0AD81072042664969247C9253BFFDCC3317, _recipient=0x458219485Fd43D9e62ddE453f854cede0afB5913, _relayer=0x0b97Abcab8675c425668863dA906c41DE4595882, _fee=117451940, _refund=20000000000000000 )
  • Verifier.verifyProof( proof=0x1FEF890101B46EAEE8228366A86776BF64D810BD3AE43B44F9E54C47B61AA36B1CB0EDD280F45A4CC1D2F3C5CDE5CF143711B49D2340995FCA14C808A922F1091C469B84881FC39B07BF6C0B8677CCF2CB0E2944421FC64652424F754FEA3255025F31A216D1E7A7ED96903494EE203B8963AD794D36A5099229A3AE740FBAE91CD88DC69B57B6D1F31016A9428957DA180C287276FEB26B818941678FC5C875115D4F7193AAA5DC58737CF1AA77A74E1BEF1F151A845EBCDB9EFE29D95570E527EBFE96537DB36098290AAA4C1A260C1D9A55C171831BBA786C44FB76DAEF7713EE83734EB8E97CFBD1349CAB0800F535A07A1938694715E208B65FA3503BF0, input=[7571624709234173005822050649508988981414736165877621745591782705286117229557, 17791419046768149783005224105424380884591406429198523801845451002860471595799, 396821662497511296803431779109894236404132305171, 66181276187087436931020611223013075673335552130, 117451940, 20000000000000000] ) => ( True )
    • Null: 0x000...006.00000000( )
    • Null: 0x000...007.1c7b2adf( )
    • Null: 0x000...006.23df1bc9( )
    • Null: 0x000...007.1cecfe92( )
    • Null: 0x000...006.0f90817d( )
    • Null: 0x000...007.1584616a( )
    • Null: 0x000...006.06a5b9e9( )
    • Null: 0x000...007.12fbb5bf( )
    • Null: 0x000...006.1de22b2e( )
    • Null: 0x000...007.0adb5137( )
    • Null: 0x000...006.17e05161( )
    • Null: 0x000...007.21e7c9bf( )
    • Null: 0x000...006.2012fc0f( )
    • Null: 0x000...008.1fef8901( )
    • TetherToken.transfer( _to=0x458219485Fd43D9e62ddE453f854cede0afB5913, _value=882548060 )
    • TetherToken.transfer( _to=0x0b97Abcab8675c425668863dA906c41DE4595882, _value=117451940 )
    • ETH 0.02 0x458219485fd43d9e62dde453f854cede0afb5913.CALL( )
      File 1 of 3: TornadoCash_erc20
      // https://tornado.cash
      /*
      * d888888P                                           dP              a88888b.                   dP
      *    88                                              88             d8'   `88                   88
      *    88    .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b.    88        .d8888b. .d8888b. 88d888b.
      *    88    88'  `88 88'  `88 88'  `88 88'  `88 88'  `88 88'  `88    88        88'  `88 Y8ooooo. 88'  `88
      *    88    88.  .88 88       88    88 88.  .88 88.  .88 88.  .88 dP Y8.   .88 88.  .88       88 88    88
      *    dP    `88888P' dP       dP    dP `88888P8 `88888P8 `88888P' 88  Y88888P' `88888P8 `88888P' dP    dP
      * ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
      */
      
      pragma solidity ^0.5.8;
      
      library Hasher {
        function MiMCSponge(uint256 in_xL, uint256 in_xR) public pure returns (uint256 xL, uint256 xR);
      }
      
      contract MerkleTreeWithHistory {
        uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
        uint256 public constant ZERO_VALUE = 21663839004416932945382355908790599225266501822907911457504978515578255421292; // = keccak256("tornado") % FIELD_SIZE
      
        uint32 public levels;
      
        // the following variables are made public for easier testing and debugging and
        // are not supposed to be accessed in regular code
        bytes32[] public filledSubtrees;
        bytes32[] public zeros;
        uint32 public currentRootIndex = 0;
        uint32 public nextIndex = 0;
        uint32 public constant ROOT_HISTORY_SIZE = 100;
        bytes32[ROOT_HISTORY_SIZE] public roots;
      
        constructor(uint32 _treeLevels) public {
          require(_treeLevels > 0, "_treeLevels should be greater than zero");
          require(_treeLevels < 32, "_treeLevels should be less than 32");
          levels = _treeLevels;
      
          bytes32 currentZero = bytes32(ZERO_VALUE);
          zeros.push(currentZero);
          filledSubtrees.push(currentZero);
      
          for (uint32 i = 1; i < levels; i++) {
            currentZero = hashLeftRight(currentZero, currentZero);
            zeros.push(currentZero);
            filledSubtrees.push(currentZero);
          }
      
          roots[0] = hashLeftRight(currentZero, currentZero);
        }
      
        /**
          @dev Hash 2 tree leaves, returns MiMC(_left, _right)
        */
        function hashLeftRight(bytes32 _left, bytes32 _right) public pure returns (bytes32) {
          require(uint256(_left) < FIELD_SIZE, "_left should be inside the field");
          require(uint256(_right) < FIELD_SIZE, "_right should be inside the field");
          uint256 R = uint256(_left);
          uint256 C = 0;
          (R, C) = Hasher.MiMCSponge(R, C);
          R = addmod(R, uint256(_right), FIELD_SIZE);
          (R, C) = Hasher.MiMCSponge(R, C);
          return bytes32(R);
        }
      
        function _insert(bytes32 _leaf) internal returns(uint32 index) {
          uint32 currentIndex = nextIndex;
          require(currentIndex != uint32(2)**levels, "Merkle tree is full. No more leafs can be added");
          nextIndex += 1;
          bytes32 currentLevelHash = _leaf;
          bytes32 left;
          bytes32 right;
      
          for (uint32 i = 0; i < levels; i++) {
            if (currentIndex % 2 == 0) {
              left = currentLevelHash;
              right = zeros[i];
      
              filledSubtrees[i] = currentLevelHash;
            } else {
              left = filledSubtrees[i];
              right = currentLevelHash;
            }
      
            currentLevelHash = hashLeftRight(left, right);
      
            currentIndex /= 2;
          }
      
          currentRootIndex = (currentRootIndex + 1) % ROOT_HISTORY_SIZE;
          roots[currentRootIndex] = currentLevelHash;
          return nextIndex - 1;
        }
      
        /**
          @dev Whether the root is present in the root history
        */
        function isKnownRoot(bytes32 _root) public view returns(bool) {
          if (_root == 0) {
            return false;
          }
          uint32 i = currentRootIndex;
          do {
            if (_root == roots[i]) {
              return true;
            }
            if (i == 0) {
              i = ROOT_HISTORY_SIZE;
            }
            i--;
          } while (i != currentRootIndex);
          return false;
        }
      
        /**
          @dev Returns the last root
        */
        function getLastRoot() public view returns(bytes32) {
          return roots[currentRootIndex];
        }
      }
      
      // File: @openzeppelin/contracts/utils/ReentrancyGuard.sol
      
      pragma solidity ^0.5.0;
      
      /**
       * @dev Contract module that helps prevent reentrant calls to a function.
       *
       * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
       * available, which can be applied to functions to make sure there are no nested
       * (reentrant) calls to them.
       *
       * Note that because there is a single `nonReentrant` guard, functions marked as
       * `nonReentrant` may not call one another. This can be worked around by making
       * those functions `private`, and then adding `external` `nonReentrant` entry
       * points to them.
       */
      contract ReentrancyGuard {
          // counter to allow mutex lock with only one SSTORE operation
          uint256 private _guardCounter;
      
          constructor () internal {
              // The counter starts at one to prevent changing it from zero to a non-zero
              // value, which is a more expensive operation.
              _guardCounter = 1;
          }
      
          /**
           * @dev Prevents a contract from calling itself, directly or indirectly.
           * Calling a `nonReentrant` function from another `nonReentrant`
           * function is not supported. It is possible to prevent this from happening
           * by making the `nonReentrant` function external, and make it call a
           * `private` function that does the actual work.
           */
          modifier nonReentrant() {
              _guardCounter += 1;
              uint256 localCounter = _guardCounter;
              _;
              require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
          }
      }
      
      // File: contracts/Tornado.sol
      
      // https://tornado.cash
      /*
      * d888888P                                           dP              a88888b.                   dP
      *    88                                              88             d8'   `88                   88
      *    88    .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b.    88        .d8888b. .d8888b. 88d888b.
      *    88    88'  `88 88'  `88 88'  `88 88'  `88 88'  `88 88'  `88    88        88'  `88 Y8ooooo. 88'  `88
      *    88    88.  .88 88       88    88 88.  .88 88.  .88 88.  .88 dP Y8.   .88 88.  .88       88 88    88
      *    dP    `88888P' dP       dP    dP `88888P8 `88888P8 `88888P' 88  Y88888P' `88888P8 `88888P' dP    dP
      * ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
      */
      
      pragma solidity ^0.5.8;
      
      
      
      contract IVerifier {
        function verifyProof(bytes memory _proof, uint256[6] memory _input) public returns(bool);
      }
      
      contract Tornado is MerkleTreeWithHistory, ReentrancyGuard {
        uint256 public denomination;
        mapping(bytes32 => bool) public nullifierHashes;
        // we store all commitments just to prevent accidental deposits with the same commitment
        mapping(bytes32 => bool) public commitments;
        IVerifier public verifier;
      
        // operator can update snark verification key
        // after the final trusted setup ceremony operator rights are supposed to be transferred to zero address
        address public operator;
        modifier onlyOperator {
          require(msg.sender == operator, "Only operator can call this function.");
          _;
        }
      
        event Deposit(bytes32 indexed commitment, uint32 leafIndex, uint256 timestamp);
        event Withdrawal(address to, bytes32 nullifierHash, address indexed relayer, uint256 fee);
      
        /**
          @dev The constructor
          @param _verifier the address of SNARK verifier for this contract
          @param _denomination transfer amount for each deposit
          @param _merkleTreeHeight the height of deposits' Merkle Tree
          @param _operator operator address (see operator comment above)
        */
        constructor(
          IVerifier _verifier,
          uint256 _denomination,
          uint32 _merkleTreeHeight,
          address _operator
        ) MerkleTreeWithHistory(_merkleTreeHeight) public {
          require(_denomination > 0, "denomination should be greater than 0");
          verifier = _verifier;
          operator = _operator;
          denomination = _denomination;
        }
      
        /**
          @dev Deposit funds into the contract. The caller must send (for ETH) or approve (for ERC20) value equal to or `denomination` of this instance.
          @param _commitment the note commitment, which is PedersenHash(nullifier + secret)
        */
        function deposit(bytes32 _commitment) external payable nonReentrant {
          require(!commitments[_commitment], "The commitment has been submitted");
      
          uint32 insertedIndex = _insert(_commitment);
          commitments[_commitment] = true;
          _processDeposit();
      
          emit Deposit(_commitment, insertedIndex, block.timestamp);
        }
      
        /** @dev this function is defined in a child contract */
        function _processDeposit() internal;
      
        /**
          @dev Withdraw a deposit from the contract. `proof` is a zkSNARK proof data, and input is an array of circuit public inputs
          `input` array consists of:
            - merkle root of all deposits in the contract
            - hash of unique deposit nullifier to prevent double spends
            - the recipient of funds
            - optional fee that goes to the transaction sender (usually a relay)
        */
        function withdraw(bytes calldata _proof, bytes32 _root, bytes32 _nullifierHash, address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) external payable nonReentrant {
          require(_fee <= denomination, "Fee exceeds transfer value");
          require(!nullifierHashes[_nullifierHash], "The note has been already spent");
          require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one
          require(verifier.verifyProof(_proof, [uint256(_root), uint256(_nullifierHash), uint256(_recipient), uint256(_relayer), _fee, _refund]), "Invalid withdraw proof");
      
          nullifierHashes[_nullifierHash] = true;
          _processWithdraw(_recipient, _relayer, _fee, _refund);
          emit Withdrawal(_recipient, _nullifierHash, _relayer, _fee);
        }
      
        /** @dev this function is defined in a child contract */
        function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal;
      
        /** @dev whether a note is already spent */
        function isSpent(bytes32 _nullifierHash) public view returns(bool) {
          return nullifierHashes[_nullifierHash];
        }
      
        /** @dev whether an array of notes is already spent */
        function isSpentArray(bytes32[] calldata _nullifierHashes) external view returns(bool[] memory spent) {
          spent = new bool[](_nullifierHashes.length);
          for(uint i = 0; i < _nullifierHashes.length; i++) {
            if (isSpent(_nullifierHashes[i])) {
              spent[i] = true;
            }
          }
        }
      
        /**
          @dev allow operator to update SNARK verification keys. This is needed to update keys after the final trusted setup ceremony is held.
          After that operator rights are supposed to be transferred to zero address
        */
        function updateVerifier(address _newVerifier) external onlyOperator {
          verifier = IVerifier(_newVerifier);
        }
      
        /** @dev operator can change his address */
        function changeOperator(address _newOperator) external onlyOperator {
          operator = _newOperator;
        }
      }
      
      // File: contracts/ERC20Tornado.sol
      
      // https://tornado.cash
      /*
      * d888888P                                           dP              a88888b.                   dP
      *    88                                              88             d8'   `88                   88
      *    88    .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b.    88        .d8888b. .d8888b. 88d888b.
      *    88    88'  `88 88'  `88 88'  `88 88'  `88 88'  `88 88'  `88    88        88'  `88 Y8ooooo. 88'  `88
      *    88    88.  .88 88       88    88 88.  .88 88.  .88 88.  .88 dP Y8.   .88 88.  .88       88 88    88
      *    dP    `88888P' dP       dP    dP `88888P8 `88888P8 `88888P' 88  Y88888P' `88888P8 `88888P' dP    dP
      * ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
      */
      
      pragma solidity ^0.5.8;
      
      
      contract TornadoCash_erc20 is Tornado {
        address public token;
      
        constructor(
          IVerifier _verifier,
          uint256 _denomination,
          uint32 _merkleTreeHeight,
          address _operator,
          address _token
        ) Tornado(_verifier, _denomination, _merkleTreeHeight, _operator) public {
          token = _token;
        }
      
        function _processDeposit() internal {
          require(msg.value == 0, "ETH value is supposed to be 0 for ERC20 instance");
          _safeErc20TransferFrom(msg.sender, address(this), denomination);
        }
      
        function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal {
          require(msg.value == _refund, "Incorrect refund amount received by the contract");
      
          _safeErc20Transfer(_recipient, denomination - _fee);
          if (_fee > 0) {
            _safeErc20Transfer(_relayer, _fee);
          }
      
          if (_refund > 0) {
            (bool success, ) = _recipient.call.value(_refund)("");
            if (!success) {
              // let's return _refund back to the relayer
              _relayer.transfer(_refund);
            }
          }
        }
      
        function _safeErc20TransferFrom(address _from, address _to, uint256 _amount) internal {
          (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd /* transferFrom */, _from, _to, _amount));
          require(success, "not enough allowed tokens");
      
          // if contract returns some data lets make sure that is `true` according to standard
          if (data.length > 0) {
            require(data.length == 32, "data length should be either 0 or 32 bytes");
            success = abi.decode(data, (bool));
            require(success, "not enough allowed tokens. Token returns false.");
          }
        }
      
        function _safeErc20Transfer(address _to, uint256 _amount) internal {
          (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb /* transfer */, _to, _amount));
          require(success, "not enough tokens");
      
          // if contract returns some data lets make sure that is `true` according to standard
          if (data.length > 0) {
            require(data.length == 32, "data length should be either 0 or 32 bytes");
            success = abi.decode(data, (bool));
            require(success, "not enough tokens. Token returns false.");
          }
        }
      }

      File 2 of 3: TetherToken
      pragma solidity ^0.4.17;
      
      /**
       * @title SafeMath
       * @dev Math operations with safety checks that throw on error
       */
      library SafeMath {
          function mul(uint256 a, uint256 b) internal pure returns (uint256) {
              if (a == 0) {
                  return 0;
              }
              uint256 c = a * b;
              assert(c / a == b);
              return c;
          }
      
          function div(uint256 a, uint256 b) internal pure returns (uint256) {
              // assert(b > 0); // Solidity automatically throws when dividing by 0
              uint256 c = a / b;
              // assert(a == b * c + a % b); // There is no case in which this doesn't hold
              return c;
          }
      
          function sub(uint256 a, uint256 b) internal pure returns (uint256) {
              assert(b <= a);
              return a - b;
          }
      
          function add(uint256 a, uint256 b) internal pure returns (uint256) {
              uint256 c = a + b;
              assert(c >= a);
              return c;
          }
      }
      
      /**
       * @title Ownable
       * @dev The Ownable contract has an owner address, and provides basic authorization control
       * functions, this simplifies the implementation of "user permissions".
       */
      contract Ownable {
          address public owner;
      
          /**
            * @dev The Ownable constructor sets the original `owner` of the contract to the sender
            * account.
            */
          function Ownable() public {
              owner = msg.sender;
          }
      
          /**
            * @dev Throws if called by any account other than the owner.
            */
          modifier onlyOwner() {
              require(msg.sender == owner);
              _;
          }
      
          /**
          * @dev Allows the current owner to transfer control of the contract to a newOwner.
          * @param newOwner The address to transfer ownership to.
          */
          function transferOwnership(address newOwner) public onlyOwner {
              if (newOwner != address(0)) {
                  owner = newOwner;
              }
          }
      
      }
      
      /**
       * @title ERC20Basic
       * @dev Simpler version of ERC20 interface
       * @dev see https://github.com/ethereum/EIPs/issues/20
       */
      contract ERC20Basic {
          uint public _totalSupply;
          function totalSupply() public constant returns (uint);
          function balanceOf(address who) public constant returns (uint);
          function transfer(address to, uint value) public;
          event Transfer(address indexed from, address indexed to, uint value);
      }
      
      /**
       * @title ERC20 interface
       * @dev see https://github.com/ethereum/EIPs/issues/20
       */
      contract ERC20 is ERC20Basic {
          function allowance(address owner, address spender) public constant returns (uint);
          function transferFrom(address from, address to, uint value) public;
          function approve(address spender, uint value) public;
          event Approval(address indexed owner, address indexed spender, uint value);
      }
      
      /**
       * @title Basic token
       * @dev Basic version of StandardToken, with no allowances.
       */
      contract BasicToken is Ownable, ERC20Basic {
          using SafeMath for uint;
      
          mapping(address => uint) public balances;
      
          // additional variables for use if transaction fees ever became necessary
          uint public basisPointsRate = 0;
          uint public maximumFee = 0;
      
          /**
          * @dev Fix for the ERC20 short address attack.
          */
          modifier onlyPayloadSize(uint size) {
              require(!(msg.data.length < size + 4));
              _;
          }
      
          /**
          * @dev transfer token for a specified address
          * @param _to The address to transfer to.
          * @param _value The amount to be transferred.
          */
          function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
              uint fee = (_value.mul(basisPointsRate)).div(10000);
              if (fee > maximumFee) {
                  fee = maximumFee;
              }
              uint sendAmount = _value.sub(fee);
              balances[msg.sender] = balances[msg.sender].sub(_value);
              balances[_to] = balances[_to].add(sendAmount);
              if (fee > 0) {
                  balances[owner] = balances[owner].add(fee);
                  Transfer(msg.sender, owner, fee);
              }
              Transfer(msg.sender, _to, sendAmount);
          }
      
          /**
          * @dev Gets the balance of the specified address.
          * @param _owner The address to query the the balance of.
          * @return An uint representing the amount owned by the passed address.
          */
          function balanceOf(address _owner) public constant returns (uint balance) {
              return balances[_owner];
          }
      
      }
      
      /**
       * @title Standard ERC20 token
       *
       * @dev Implementation of the basic standard token.
       * @dev https://github.com/ethereum/EIPs/issues/20
       * @dev Based oncode by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
       */
      contract StandardToken is BasicToken, ERC20 {
      
          mapping (address => mapping (address => uint)) public allowed;
      
          uint public constant MAX_UINT = 2**256 - 1;
      
          /**
          * @dev Transfer tokens from one address to another
          * @param _from address The address which you want to send tokens from
          * @param _to address The address which you want to transfer to
          * @param _value uint the amount of tokens to be transferred
          */
          function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
              var _allowance = allowed[_from][msg.sender];
      
              // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
              // if (_value > _allowance) throw;
      
              uint fee = (_value.mul(basisPointsRate)).div(10000);
              if (fee > maximumFee) {
                  fee = maximumFee;
              }
              if (_allowance < MAX_UINT) {
                  allowed[_from][msg.sender] = _allowance.sub(_value);
              }
              uint sendAmount = _value.sub(fee);
              balances[_from] = balances[_from].sub(_value);
              balances[_to] = balances[_to].add(sendAmount);
              if (fee > 0) {
                  balances[owner] = balances[owner].add(fee);
                  Transfer(_from, owner, fee);
              }
              Transfer(_from, _to, sendAmount);
          }
      
          /**
          * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
          * @param _spender The address which will spend the funds.
          * @param _value The amount of tokens to be spent.
          */
          function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
      
              // To change the approve amount you first have to reduce the addresses`
              //  allowance to zero by calling `approve(_spender, 0)` if it is not
              //  already 0 to mitigate the race condition described here:
              //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
              require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));
      
              allowed[msg.sender][_spender] = _value;
              Approval(msg.sender, _spender, _value);
          }
      
          /**
          * @dev Function to check the amount of tokens than an owner allowed to a spender.
          * @param _owner address The address which owns the funds.
          * @param _spender address The address which will spend the funds.
          * @return A uint specifying the amount of tokens still available for the spender.
          */
          function allowance(address _owner, address _spender) public constant returns (uint remaining) {
              return allowed[_owner][_spender];
          }
      
      }
      
      
      /**
       * @title Pausable
       * @dev Base contract which allows children to implement an emergency stop mechanism.
       */
      contract Pausable is Ownable {
        event Pause();
        event Unpause();
      
        bool public paused = false;
      
      
        /**
         * @dev Modifier to make a function callable only when the contract is not paused.
         */
        modifier whenNotPaused() {
          require(!paused);
          _;
        }
      
        /**
         * @dev Modifier to make a function callable only when the contract is paused.
         */
        modifier whenPaused() {
          require(paused);
          _;
        }
      
        /**
         * @dev called by the owner to pause, triggers stopped state
         */
        function pause() onlyOwner whenNotPaused public {
          paused = true;
          Pause();
        }
      
        /**
         * @dev called by the owner to unpause, returns to normal state
         */
        function unpause() onlyOwner whenPaused public {
          paused = false;
          Unpause();
        }
      }
      
      contract BlackList is Ownable, BasicToken {
      
          /////// Getters to allow the same blacklist to be used also by other contracts (including upgraded Tether) ///////
          function getBlackListStatus(address _maker) external constant returns (bool) {
              return isBlackListed[_maker];
          }
      
          function getOwner() external constant returns (address) {
              return owner;
          }
      
          mapping (address => bool) public isBlackListed;
          
          function addBlackList (address _evilUser) public onlyOwner {
              isBlackListed[_evilUser] = true;
              AddedBlackList(_evilUser);
          }
      
          function removeBlackList (address _clearedUser) public onlyOwner {
              isBlackListed[_clearedUser] = false;
              RemovedBlackList(_clearedUser);
          }
      
          function destroyBlackFunds (address _blackListedUser) public onlyOwner {
              require(isBlackListed[_blackListedUser]);
              uint dirtyFunds = balanceOf(_blackListedUser);
              balances[_blackListedUser] = 0;
              _totalSupply -= dirtyFunds;
              DestroyedBlackFunds(_blackListedUser, dirtyFunds);
          }
      
          event DestroyedBlackFunds(address _blackListedUser, uint _balance);
      
          event AddedBlackList(address _user);
      
          event RemovedBlackList(address _user);
      
      }
      
      contract UpgradedStandardToken is StandardToken{
          // those methods are called by the legacy contract
          // and they must ensure msg.sender to be the contract address
          function transferByLegacy(address from, address to, uint value) public;
          function transferFromByLegacy(address sender, address from, address spender, uint value) public;
          function approveByLegacy(address from, address spender, uint value) public;
      }
      
      contract TetherToken is Pausable, StandardToken, BlackList {
      
          string public name;
          string public symbol;
          uint public decimals;
          address public upgradedAddress;
          bool public deprecated;
      
          //  The contract can be initialized with a number of tokens
          //  All the tokens are deposited to the owner address
          //
          // @param _balance Initial supply of the contract
          // @param _name Token Name
          // @param _symbol Token symbol
          // @param _decimals Token decimals
          function TetherToken(uint _initialSupply, string _name, string _symbol, uint _decimals) public {
              _totalSupply = _initialSupply;
              name = _name;
              symbol = _symbol;
              decimals = _decimals;
              balances[owner] = _initialSupply;
              deprecated = false;
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function transfer(address _to, uint _value) public whenNotPaused {
              require(!isBlackListed[msg.sender]);
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value);
              } else {
                  return super.transfer(_to, _value);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function transferFrom(address _from, address _to, uint _value) public whenNotPaused {
              require(!isBlackListed[_from]);
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value);
              } else {
                  return super.transferFrom(_from, _to, _value);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function balanceOf(address who) public constant returns (uint) {
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).balanceOf(who);
              } else {
                  return super.balanceOf(who);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value);
              } else {
                  return super.approve(_spender, _value);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function allowance(address _owner, address _spender) public constant returns (uint remaining) {
              if (deprecated) {
                  return StandardToken(upgradedAddress).allowance(_owner, _spender);
              } else {
                  return super.allowance(_owner, _spender);
              }
          }
      
          // deprecate current contract in favour of a new one
          function deprecate(address _upgradedAddress) public onlyOwner {
              deprecated = true;
              upgradedAddress = _upgradedAddress;
              Deprecate(_upgradedAddress);
          }
      
          // deprecate current contract if favour of a new one
          function totalSupply() public constant returns (uint) {
              if (deprecated) {
                  return StandardToken(upgradedAddress).totalSupply();
              } else {
                  return _totalSupply;
              }
          }
      
          // Issue a new amount of tokens
          // these tokens are deposited into the owner address
          //
          // @param _amount Number of tokens to be issued
          function issue(uint amount) public onlyOwner {
              require(_totalSupply + amount > _totalSupply);
              require(balances[owner] + amount > balances[owner]);
      
              balances[owner] += amount;
              _totalSupply += amount;
              Issue(amount);
          }
      
          // Redeem tokens.
          // These tokens are withdrawn from the owner address
          // if the balance must be enough to cover the redeem
          // or the call will fail.
          // @param _amount Number of tokens to be issued
          function redeem(uint amount) public onlyOwner {
              require(_totalSupply >= amount);
              require(balances[owner] >= amount);
      
              _totalSupply -= amount;
              balances[owner] -= amount;
              Redeem(amount);
          }
      
          function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner {
              // Ensure transparency by hardcoding limit beyond which fees can never be added
              require(newBasisPoints < 20);
              require(newMaxFee < 50);
      
              basisPointsRate = newBasisPoints;
              maximumFee = newMaxFee.mul(10**decimals);
      
              Params(basisPointsRate, maximumFee);
          }
      
          // Called when new token are issued
          event Issue(uint amount);
      
          // Called when tokens are redeemed
          event Redeem(uint amount);
      
          // Called when contract is deprecated
          event Deprecate(address newAddress);
      
          // Called if contract ever adds fees
          event Params(uint feeBasisPoints, uint maxFee);
      }

      File 3 of 3: Verifier
      // https://tornado.cash Verifier.sol generated by trusted setup ceremony.
      /*
      * d888888P                                           dP              a88888b.                   dP
      *    88                                              88             d8'   `88                   88
      *    88    .d8888b. 88d888b. 88d888b. .d8888b. .d888b88 .d8888b.    88        .d8888b. .d8888b. 88d888b.
      *    88    88'  `88 88'  `88 88'  `88 88'  `88 88'  `88 88'  `88    88        88'  `88 Y8ooooo. 88'  `88
      *    88    88.  .88 88       88    88 88.  .88 88.  .88 88.  .88 dP Y8.   .88 88.  .88       88 88    88
      *    dP    `88888P' dP       dP    dP `88888P8 `88888P8 `88888P' 88  Y88888P' `88888P8 `88888P' dP    dP
      * ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
      */
      // Copyright 2017 Christian Reitwiessner
      // Permission is hereby granted, free of charge, to any person obtaining a copy
      // of this software and associated documentation files (the "Software"), to
      // deal in the Software without restriction, including without limitation the
      // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
      // sell copies of the Software, and to permit persons to whom the Software is
      // furnished to do so, subject to the following conditions:
      // The above copyright notice and this permission notice shall be included in
      // all copies or substantial portions of the Software.
      // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
      // IN THE SOFTWARE.
      
      // 2019 OKIMS
      
      pragma solidity 0.5.17;
      
      library Pairing {
          uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
      
          struct G1Point {
              uint256 X;
              uint256 Y;
          }
      
          // Encoding of field elements is: X[0] * z + X[1]
          struct G2Point {
              uint256[2] X;
              uint256[2] Y;
          }
      
          /*
           * @return The negation of p, i.e. p.plus(p.negate()) should be zero.
           */
          function negate(G1Point memory p) internal pure returns (G1Point memory) {
              // The prime q in the base field F_q for G1
              if (p.X == 0 && p.Y == 0) {
                  return G1Point(0, 0);
              } else {
                  return G1Point(p.X, PRIME_Q - (p.Y % PRIME_Q));
              }
          }
      
          /*
           * @return r the sum of two points of G1
           */
          function plus(
              G1Point memory p1,
              G1Point memory p2
          ) internal view returns (G1Point memory r) {
              uint256[4] memory input;
              input[0] = p1.X;
              input[1] = p1.Y;
              input[2] = p2.X;
              input[3] = p2.Y;
              bool success;
      
              // solium-disable-next-line security/no-inline-assembly
              assembly {
                  success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60)
                  // Use "invalid" to make gas estimation work
                  switch success case 0 { invalid() }
              }
      
              require(success, "pairing-add-failed");
          }
      
          /*
           * @return r the product of a point on G1 and a scalar, i.e.
           *         p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all
           *         points p.
           */
          function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) {
              uint256[3] memory input;
              input[0] = p.X;
              input[1] = p.Y;
              input[2] = s;
              bool success;
              // solium-disable-next-line security/no-inline-assembly
              assembly {
                  success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60)
                  // Use "invalid" to make gas estimation work
                  switch success case 0 { invalid() }
              }
              require(success, "pairing-mul-failed");
          }
      
          /* @return The result of computing the pairing check
           *         e(p1[0], p2[0]) *  .... * e(p1[n], p2[n]) == 1
           *         For example,
           *         pairing([P1(), P1().negate()], [P2(), P2()]) should return true.
           */
          function pairing(
              G1Point memory a1,
              G2Point memory a2,
              G1Point memory b1,
              G2Point memory b2,
              G1Point memory c1,
              G2Point memory c2,
              G1Point memory d1,
              G2Point memory d2
          ) internal view returns (bool) {
              G1Point[4] memory p1 = [a1, b1, c1, d1];
              G2Point[4] memory p2 = [a2, b2, c2, d2];
      
              uint256 inputSize = 24;
              uint256[] memory input = new uint256[](inputSize);
      
              for (uint256 i = 0; i < 4; i++) {
                  uint256 j = i * 6;
                  input[j + 0] = p1[i].X;
                  input[j + 1] = p1[i].Y;
                  input[j + 2] = p2[i].X[0];
                  input[j + 3] = p2[i].X[1];
                  input[j + 4] = p2[i].Y[0];
                  input[j + 5] = p2[i].Y[1];
              }
      
              uint256[1] memory out;
              bool success;
      
              // solium-disable-next-line security/no-inline-assembly
              assembly {
                  success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20)
                  // Use "invalid" to make gas estimation work
                  switch success case 0 { invalid() }
              }
      
              require(success, "pairing-opcode-failed");
      
              return out[0] != 0;
          }
      }
      
      contract Verifier {
          uint256 constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
          uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
          using Pairing for *;
      
          struct VerifyingKey {
              Pairing.G1Point alfa1;
              Pairing.G2Point beta2;
              Pairing.G2Point gamma2;
              Pairing.G2Point delta2;
              Pairing.G1Point[7] IC;
          }
      
          struct Proof {
              Pairing.G1Point A;
              Pairing.G2Point B;
              Pairing.G1Point C;
          }
      
          function verifyingKey() internal pure returns (VerifyingKey memory vk) {
              vk.alfa1 = Pairing.G1Point(uint256(20692898189092739278193869274495556617788530808486270118371701516666252877969), uint256(11713062878292653967971378194351968039596396853904572879488166084231740557279));
              vk.beta2 = Pairing.G2Point([uint256(12168528810181263706895252315640534818222943348193302139358377162645029937006), uint256(281120578337195720357474965979947690431622127986816839208576358024608803542)], [uint256(16129176515713072042442734839012966563817890688785805090011011570989315559913), uint256(9011703453772030375124466642203641636825223906145908770308724549646909480510)]);
              vk.gamma2 = Pairing.G2Point([uint256(11559732032986387107991004021392285783925812861821192530917403151452391805634), uint256(10857046999023057135944570762232829481370756359578518086990519993285655852781)], [uint256(4082367875863433681332203403145435568316851327593401208105741076214120093531), uint256(8495653923123431417604973247489272438418190587263600148770280649306958101930)]);
              vk.delta2 = Pairing.G2Point([uint256(21280594949518992153305586783242820682644996932183186320680800072133486887432), uint256(150879136433974552800030963899771162647715069685890547489132178314736470662)], [uint256(1081836006956609894549771334721413187913047383331561601606260283167615953295), uint256(11434086686358152335540554643130007307617078324975981257823476472104616196090)]);
              vk.IC[0] = Pairing.G1Point(uint256(16225148364316337376768119297456868908427925829817748684139175309620217098814), uint256(5167268689450204162046084442581051565997733233062478317813755636162413164690));
              vk.IC[1] = Pairing.G1Point(uint256(12882377842072682264979317445365303375159828272423495088911985689463022094260), uint256(19488215856665173565526758360510125932214252767275816329232454875804474844786));
              vk.IC[2] = Pairing.G1Point(uint256(13083492661683431044045992285476184182144099829507350352128615182516530014777), uint256(602051281796153692392523702676782023472744522032670801091617246498551238913));
              vk.IC[3] = Pairing.G1Point(uint256(9732465972180335629969421513785602934706096902316483580882842789662669212890), uint256(2776526698606888434074200384264824461688198384989521091253289776235602495678));
              vk.IC[4] = Pairing.G1Point(uint256(8586364274534577154894611080234048648883781955345622578531233113180532234842), uint256(21276134929883121123323359450658320820075698490666870487450985603988214349407));
              vk.IC[5] = Pairing.G1Point(uint256(4910628533171597675018724709631788948355422829499855033965018665300386637884), uint256(20532468890024084510431799098097081600480376127870299142189696620752500664302));
              vk.IC[6] = Pairing.G1Point(uint256(15335858102289947642505450692012116222827233918185150176888641903531542034017), uint256(5311597067667671581646709998171703828965875677637292315055030353779531404812));
      
          }
      
          /*
           * @returns Whether the proof is valid given the hardcoded verifying key
           *          above and the public inputs
           */
          function verifyProof(
              bytes memory proof,
              uint256[6] memory input
          ) public view returns (bool) {
              uint256[8] memory p = abi.decode(proof, (uint256[8]));
      
              // Make sure that each element in the proof is less than the prime q
              for (uint8 i = 0; i < p.length; i++) {
                  require(p[i] < PRIME_Q, "verifier-proof-element-gte-prime-q");
              }
      
              Proof memory _proof;
              _proof.A = Pairing.G1Point(p[0], p[1]);
              _proof.B = Pairing.G2Point([p[2], p[3]], [p[4], p[5]]);
              _proof.C = Pairing.G1Point(p[6], p[7]);
      
              VerifyingKey memory vk = verifyingKey();
      
              // Compute the linear combination vk_x
              Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0);
              vk_x = Pairing.plus(vk_x, vk.IC[0]);
      
              // Make sure that every input is less than the snark scalar field
              for (uint256 i = 0; i < input.length; i++) {
                  require(input[i] < SNARK_SCALAR_FIELD, "verifier-gte-snark-scalar-field");
                  vk_x = Pairing.plus(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i]));
              }
      
              return Pairing.pairing(
                  Pairing.negate(_proof.A),
                  _proof.B,
                  vk.alfa1,
                  vk.beta2,
                  vk_x,
                  vk.gamma2,
                  _proof.C,
                  vk.delta2
              );
          }
      }