Contract 0x40a38911e470fc088beeb1a9480c2d69c847bcec

 

TxHash Block Age From To Value [TxFee]
0x75b04523f5db22525b47a186ba6b233659d4364b04e038991bb1e6e916c1109e6505129129 days 21 hrs agodeltabalances IN  Contract Creation0 Ether0.001495785
[ Download CSV Export 

Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
Contract Source Code Verified (Exact Match)
Contract Name: DeltaBalances
Compiler Version: v0.4.25+commit.59dbf8f1
Optimization Enabled: Yes
Runs (Optimizer):  200


Contract Source Code
pragma solidity ^0.4.25;

/* 
    Contract for DeltaBalances.github.io V4.
    Check ERC20 token balances & allowances for multiple tokens in 1 batched request.
    
    V4 changes:
    - Small optimizations.
    - Add token allowances.
    - Removed unused functions.
    
    For the previous versions, see 0x3E25F0BA291F202188Ae9Bda3004A7B3a803599a for code and comments.
    
    Address 0x0 is used to indicate ETH (as used in EtherDelta, IDEX and more).
*/

// Exchange contract Interface for EtherDelta and forks.
contract Exchange {
  function balanceOf(address token, address user) public view returns (uint);
}

// ERC20 contract interface.
contract Token {
  function balanceOf(address tokenOwner) public view returns (uint balance);
  function transfer(address to, uint tokens) public returns (bool success);
  function allowance(address tokenOwner, address spenderContract) public view returns (uint remaining);
}

contract DeltaBalances {
    
  address public admin; 

  constructor() public {
    admin = msg.sender;
  }

  // Limit withdrawals to the contract creator.
  modifier isAdmin() {
    require(msg.sender == admin);
    _;
  }


  // Backup withdraw, in case ETH gets in here.
  function withdraw() external isAdmin {
    admin.transfer(address(this).balance);
  }

  // Backup withdraw, in case ERC20 tokens get in here.
  function withdrawToken(address token, uint amount) external isAdmin {
    require(token != address(0x0) && Token(token).transfer(msg.sender, amount));
  }


  /* Check the token balances of a wallet for multiple tokens.
     Returns array of token balances in wei units. */
  function tokenBalances(address user,  address[] tokens) external view returns (uint[]) {
    uint[] memory balances = new uint[](tokens.length);
    
    for(uint i = 0; i < tokens.length; i++) {
      if(tokens[i] != address(0x0)) { 
        balances[i] = tokenBalance(user, tokens[i]); // check token balance and catch errors
      } else {
        balances[i] = user.balance; // ETH balance    
      }
    }    
    return balances;
  }


  /* Get multiple token balances deposited on a DEX (EtherDelta, IDEX, or similar exchange).
     Returns array of deposited token balances in wei units. */
  function depositedBalances(address exchange, address user, address[] tokens) external view returns (uint[]) {
    Exchange ex = Exchange(exchange);
    uint[] memory balances = new uint[](tokens.length);
    
    for(uint i = 0; i < tokens.length; i++) {
      balances[i] = ex.balanceOf(tokens[i], user); //might error if exchange does not implement balanceOf correctly
    }    
    return balances;
  }

  /* Get multiple token allowances for a contract.
     Returns array of deposited token balances in wei units. */
  function tokenAllowances(address spenderContract, address user, address[] tokens) external view returns (uint[]) {
    uint[] memory allowances = new uint[](tokens.length);
    
    for(uint i = 0; i < tokens.length; i++) {
      allowances[i] = tokenAllowance(spenderContract, user, tokens[i]); // check token allowance and catch errors
    }    
    return allowances;
  }


 /* Check the token balance of a wallet in a token contract.
    Returns 0 on a bad token contract   */
  function tokenBalance(address user, address token) internal view returns (uint) {
    // check if token is actually a contract
    uint256 tokenCode;
    assembly { tokenCode := extcodesize(token) } // contract code size
   
   // is it a contract and does it implement balanceOf() 
    if(tokenCode > 0 && token.call(0x70a08231, user)) {    // bytes4(keccak256("balanceOf(address)")) == 0x70a08231  
      return Token(token).balanceOf(user);
    } else {
      return 0; // not a valid token, return 0 instead of error
    }
  }
  
  
  /* Check the token allowance of a wallet for a specific contract.
     Returns 0 on a bad token contract.   */
  function tokenAllowance(address spenderContract, address user, address token) internal view returns (uint) {
    // check if token is actually a contract
    uint256 tokenCode;
    assembly { tokenCode := extcodesize(token) } // contract code size
   
   // is it a contract and does it implement allowance() 
    if(tokenCode > 0 && token.call(0xdd62ed3e, user, spenderContract)) {    // bytes4(keccak256("allowance(address,address)")) == 0xdd62ed3e
      return Token(token).allowance(user, spenderContract);
    } else {
      return 0; // not a valid token, return 0 instead of error
    }
  }
}

Contract ABI
[{"constant":true,"inputs":[{"name":"exchange","type":"address"},{"name":"user","type":"address"},{"name":"tokens","type":"address[]"}],"name":"depositedBalances","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"tokens","type":"address[]"}],"name":"tokenBalances","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"amount","type":"uint256"}],"name":"withdrawToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"spenderContract","type":"address"},{"name":"user","type":"address"},{"name":"tokens","type":"address[]"}],"name":"tokenAllowances","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]

Contract Creation Code
608060405234801561001057600080fd5b5060008054600160a060020a031916331790556107be806100326000396000f30060806040526004361061005e5763ffffffff60e060020a6000350416631621c4e581146100635780633ad206cc146100e85780633ccfd60b146101155780639e281a981461012c578063ed58350614610150578063f851a44014610185575b600080fd5b34801561006f57600080fd5b50610098600160a060020a036004803582169160248035909116916044359182019101356101b6565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156100d45781810151838201526020016100bc565b505050509050019250505060405180910390f35b3480156100f457600080fd5b5061009860048035600160a060020a031690602480359081019101356102c1565b34801561012157600080fd5b5061012a6103a8565b005b34801561013857600080fd5b5061012a600160a060020a03600435166024356103fd565b34801561015c57600080fd5b50610098600160a060020a036004803582169160248035909116916044359182019101356104cb565b34801561019157600080fd5b5061019a61055d565b60408051600160a060020a039092168252519081900360200190f35b604080518281526020808402820101909152606090859082906000908580156101e9578160200160208202803883390190505b509150600090505b848110156102b657600160a060020a03831663f7888aec87878481811061021457fe5b6040805160e060020a63ffffffff8716028152600160a060020a036020938402959095013585166004820152938d1660248501525160448085019492935090918290030181600087803b15801561026a57600080fd5b505af115801561027e573d6000803e3d6000fd5b505050506040513d602081101561029457600080fd5b505182518390839081106102a457fe5b602090810290910101526001016101f1565b509695505050505050565b6060806000848490506040519080825280602002602001820160405280156102f3578160200160208202803883390190505b509150600090505b8381101561039f57600085858381811061031157fe5b90506020020135600160a060020a0316600160a060020a0316141515610373576103568686868481811061034157fe5b90506020020135600160a060020a031661056c565b828281518110151561036457fe5b60209081029091010152610397565b85600160a060020a031631828281518110151561038c57fe5b602090810290910101525b6001016102fb565b50949350505050565b600054600160a060020a031633146103bf57600080fd5b60008054604051600160a060020a0390911691303180156108fc02929091818181858888f193505050501580156103fa573d6000803e3d6000fd5b50565b600054600160a060020a0316331461041457600080fd5b600160a060020a038216158015906104bc5750604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018390529051600160a060020a0384169163a9059cbb9160448083019260209291908290030181600087803b15801561048f57600080fd5b505af11580156104a3573d6000803e3d6000fd5b505050506040513d60208110156104b957600080fd5b50515b15156104c757600080fd5b5050565b6060806000848490506040519080825280602002602001820160405280156104fd578160200160208202803883390190505b509150600090505b8381101561055357610533878787878581811061051e57fe5b90506020020135600160a060020a031661066d565b828281518110151561054157fe5b60209081029091010152600101610505565b5095945050505050565b600054600160a060020a031681565b6000813b81811180156105ce575082600160a060020a03166370a08231856040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a031681526020019150506000604051808303816000875af1925050505b156106615782600160a060020a03166370a08231856040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b505050506040513d602081101561065857600080fd5b50519150610666565b600091505b5092915050565b6000813b81811180156106e05750604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152878116602483015291519185169163dd62ed3e91604480820192600092909190829003018183875af1925050505b1561078557604080517fdd62ed3e000000000000000000000000000000000000000000000000000000008152600160a060020a038681166004830152878116602483015291519185169163dd62ed3e916044808201926020929091908290030181600087803b15801561075257600080fd5b505af1158015610766573d6000803e3d6000fd5b505050506040513d602081101561077c57600080fd5b5051915061078a565b600091505b5093925050505600a165627a7a72305820045d535b6d5ce7605d3e076616b0859a93bba3a5f3f00de0d534d3dba357160b0029


   Swarm Source:
bzzr://045d535b6d5ce7605d3e076616b0859a93bba3a5f3f00de0d534d3dba357160b
Block Age transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.