S Price: $0.506641 (-6.41%)

Contract

0x9C36Cc67EfE5faA3B8afAF17E653c399a3cb12c4

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BalanceChecker

Compiler Version
v0.4.26+commit.4563c3fc

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion, None license
/**
 *Submitted for verification at SonicScan.org on 2024-12-27
*/

// Built off of https://github.com/DeltaBalances/DeltaBalances.github.io/blob/master/smart_contract/deltabalances.sol
pragma solidity ^0.4.21;

// ERC20 contract interface
contract Token {
  function balanceOf(address) public view returns (uint);
}

contract BalanceChecker {
  /* Fallback function, don't accept any ETH */
  function() public payable {
    revert("BalanceChecker does not accept payments");
  }

  /*
    Check the token balance of a wallet in a token contract

    Returns the balance of the token for user. Avoids possible errors:
      - return 0 on non-contract address 
      - returns 0 if the contract doesn't implement balanceOf
  */
  function tokenBalance(address user, address token) public 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(bytes4(0x70a08231), user)) {  
      return Token(token).balanceOf(user);
    } else {
      return 0;
    }
  }

  /*
    Check the token balances of a wallet for multiple tokens.
    Pass 0x0 as a "token" address to get ETH balance.

    Possible error throws:
      - extremely large arrays for user and or tokens (gas cost too high) 
          
    Returns a one-dimensional that's user.length * tokens.length long. The
    array is ordered by all of the 0th users token balances, then the 1th
    user, and so on.
  */
  function balances(address[] users, address[] tokens) external view returns (uint[]) {
    uint[] memory addrBalances = new uint[](tokens.length * users.length);
    
    for(uint i = 0; i < users.length; i++) {
      for (uint j = 0; j < tokens.length; j++) {
        uint addrIdx = j + tokens.length * i;
        if (tokens[j] != address(0x0)) { 
          addrBalances[addrIdx] = tokenBalance(users[i], tokens[j]);
        } else {
          addrBalances[addrIdx] = users[i].balance; // ETH balance    
        }
      }  
    }
  
    return addrBalances;
  }

}

Contract Security Audit

Contract ABI

API
[{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"token","type":"address"}],"name":"tokenBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"users","type":"address[]"},{"name":"tokens","type":"address[]"}],"name":"balances","outputs":[{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"}]

608060405234801561001057600080fd5b506105d1806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631049334f146100e0578063f0002ea914610157575b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001807f42616c616e6365436865636b657220646f6573206e6f7420616363657074207081526020017f61796d656e74730000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b3480156100ec57600080fd5b50610141600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101ff565b6040518082815260200191505060405180910390f35b34801561016357600080fd5b506101a86004803603810190808035906020019082018035906020019190919293919293908035906020019082018035906020019190919293919293905050506103d2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101eb5780820151818401526020810190506101d0565b505050509050019250505060405180910390f35b600080823b90506000811180156102e457508273ffffffffffffffffffffffffffffffffffffffff166370a082317c0100000000000000000000000000000000000000000000000000000000027c01000000000000000000000000000000000000000000000000000000009004856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019150506000604051808303816000875af1925050505b156103c6578273ffffffffffffffffffffffffffffffffffffffff166370a08231856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561038457600080fd5b505af1158015610398573d6000803e3d6000fd5b505050506040513d60208110156103ae57600080fd5b810190808051906020019092919050505091506103cb565b600091505b5092915050565b60608060008060008888905087879050026040519080825280602002602001820160405280156104115781602001602082028038833980820191505090505b509350600092505b8888905083101561059657600091505b868690508210156105895782878790500282019050600073ffffffffffffffffffffffffffffffffffffffff16878784818110151561046457fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561051d576104fc89898581811015156104af57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1688888581811015156104da57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166101ff565b848281518110151561050a57fe5b906020019060200201818152505061057c565b888884818110151561052b57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631848281518110151561056d57fe5b90602001906020020181815250505b8180600101925050610429565b8280600101935050610419565b839450505050509493505050505600a165627a7a72305820f04b5d5493d4843165fe572a28e6d077ee7456c34c401012c74f25b14e58ed050029

Deployed Bytecode

0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631049334f146100e0578063f0002ea914610157575b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001807f42616c616e6365436865636b657220646f6573206e6f7420616363657074207081526020017f61796d656e74730000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b3480156100ec57600080fd5b50610141600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101ff565b6040518082815260200191505060405180910390f35b34801561016357600080fd5b506101a86004803603810190808035906020019082018035906020019190919293919293908035906020019082018035906020019190919293919293905050506103d2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101eb5780820151818401526020810190506101d0565b505050509050019250505060405180910390f35b600080823b90506000811180156102e457508273ffffffffffffffffffffffffffffffffffffffff166370a082317c0100000000000000000000000000000000000000000000000000000000027c01000000000000000000000000000000000000000000000000000000009004856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019150506000604051808303816000875af1925050505b156103c6578273ffffffffffffffffffffffffffffffffffffffff166370a08231856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561038457600080fd5b505af1158015610398573d6000803e3d6000fd5b505050506040513d60208110156103ae57600080fd5b810190808051906020019092919050505091506103cb565b600091505b5092915050565b60608060008060008888905087879050026040519080825280602002602001820160405280156104115781602001602082028038833980820191505090505b509350600092505b8888905083101561059657600091505b868690508210156105895782878790500282019050600073ffffffffffffffffffffffffffffffffffffffff16878784818110151561046457fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561051d576104fc89898581811015156104af57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1688888581811015156104da57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166101ff565b848281518110151561050a57fe5b906020019060200201818152505061057c565b888884818110151561052b57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631848281518110151561056d57fe5b90602001906020020181815250505b8180600101925050610429565b8280600101935050610419565b839450505050509493505050505600a165627a7a72305820f04b5d5493d4843165fe572a28e6d077ee7456c34c401012c74f25b14e58ed050029

Deployed Bytecode Sourcemap

258:1872:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;369:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;683:438;;8:9:-1;5:2;;;30:1;27;20:12;5:2;683:438:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1548:577;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1548:577:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;1548:577:0;;;;;;;;;;;;;;;;;683:438;755:4;814:17;874:5;862:18;849:31;;988:1;976:9;:13;:53;;;;;993:5;:10;;1011;1004:18;;993:36;;;1024:4;993:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;976:53;972:144;;;1055:5;1049:22;;;1072:4;1049:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1049:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1049:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1049:28:0;;;;;;;;;;;;;;;;1042:35;;;;972:144;1107:1;1100:8;;683:438;;;;;;:::o;1548:577::-;1624:6;1639:26;1725:6;1774;1821:12;1695:5;;:12;;1679:6;;:13;;:28;1668:40;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;1668:40:0;;;;1639:69;;1734:1;1725:10;;1721:369;1741:5;;:12;;1737:1;:16;1721:369;;;1783:1;1774:10;;1769:312;1790:6;;:13;;1786:1;:17;1769:312;;;1856:1;1840:6;;:13;;:17;1836:1;:21;1821:36;;1893:3;1872:25;;:6;;1879:1;1872:9;;;;;;;;;;;;;;;;;:25;;;;1868:204;;;1937:33;1950:5;;1956:1;1950:8;;;;;;;;;;;;;;;;;1960:6;;1967:1;1960:9;;;;;;;;;;;;;;;;;1937:12;:33::i;:::-;1913:12;1926:7;1913:21;;;;;;;;;;;;;;;;;:57;;;;;1868:204;;;2025:5;;2031:1;2025:8;;;;;;;;;;;;;;;;;:16;;;2001:12;2014:7;2001:21;;;;;;;;;;;;;;;;;:40;;;;;1868:204;1805:3;;;;;;;1769:312;;;1755:3;;;;;;;1721:369;;;2107:12;2100:19;;1548:577;;;;;;;;;;:::o

Swarm Source

bzzr://f04b5d5493d4843165fe572a28e6d077ee7456c34c401012c74f25b14e58ed05

Block Transaction Gas Used Reward
view all blocks ##produced##

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.