Mumbai Testnet

Contract

0xBd7C4B9aB1AC188E11CA046a996e378ecBB2a031

Overview

MATIC Balance

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x60806040256463732022-03-24 11:01:59797 days ago1648119719IN
 Create: BalanceHelper
0 MATIC0.002533858.50000012

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

Contract Source Code Verified (Exact Match)

Contract Name:
BalanceHelper

Compiler Version
v0.8.5+commit.a4f2e591

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 2 : BalanceHelper.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";

contract BalanceHelper {
    struct TokenBalance {
        uint256 total;
        uint256 allowance;
    }

    function balancesOf(address _user, IERC20[] memory _tokens, address _tokenSpender) public view returns (uint256 ethBalance, TokenBalance[] memory tokensBalances) {
        // Eth balance
        ethBalance = _user.balance;

        // Tokens balance
        tokensBalances = new TokenBalance[](_tokens.length);
        for (uint256 i = 0; i < _tokens.length; i++) {
            tokensBalances[i] = TokenBalance(
                _tokens[i].balanceOf(_user),
                _tokens[i].allowance(_user, _tokenSpender)
            );
        }
    }
}

File 2 of 2 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"contract IERC20[]","name":"_tokens","type":"address[]"},{"internalType":"address","name":"_tokenSpender","type":"address"}],"name":"balancesOf","outputs":[{"internalType":"uint256","name":"ethBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"allowance","type":"uint256"}],"internalType":"struct BalanceHelper.TokenBalance[]","name":"tokensBalances","type":"tuple[]"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b5061046e806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cbf4a6a014610030575b600080fd5b61004361003e366004610269565b61005a565b604051610051929190610373565b60405180910390f35b81516001600160a01b038416319060609067ffffffffffffffff8111156100835761008361040a565b6040519080825280602002602001820160405280156100c857816020015b60408051808201909152600080825260208201528152602001906001900390816100a15790505b50905060005b84518110156102505760405180604001604052808683815181106100f4576100f46103f4565b60209081029190910101516040516370a0823160e01b81526001600160a01b038a81166004830152909116906370a082319060240160206040518083038186803b15801561014157600080fd5b505afa158015610155573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610179919061035a565b8152602001868381518110610190576101906103f4565b6020908102919091010151604051636eb1769f60e11b81526001600160a01b038a8116600483015288811660248301529091169063dd62ed3e9060440160206040518083038186803b1580156101e557600080fd5b505afa1580156101f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061021d919061035a565b815250828281518110610232576102326103f4565b60200260200101819052508080610248906103cb565b9150506100ce565b50935093915050565b803561026481610420565b919050565b60008060006060848603121561027e57600080fd5b833561028981610420565b925060208481013567ffffffffffffffff808211156102a757600080fd5b818701915087601f8301126102bb57600080fd5b8135818111156102cd576102cd61040a565b8060051b604051601f19603f830116810181811085821117156102f2576102f261040a565b604052828152858101935084860182860187018c101561031157600080fd5b600095505b8386101561033b5761032781610259565b855260019590950194938601938601610316565b5080975050505050505061035160408501610259565b90509250925092565b60006020828403121561036c57600080fd5b5051919050565b6000604080830185845260208281860152818651808452606087019150828801935060005b818110156103bd57845180518452840151848401529383019391850191600101610398565b509098975050505050505050565b60006000198214156103ed57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461043557600080fd5b5056fea2646970667358221220bc120b3bf50b21bf74a77b58555c773306237a35945b643c19659f4abe67f33364736f6c63430008050033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cbf4a6a014610030575b600080fd5b61004361003e366004610269565b61005a565b604051610051929190610373565b60405180910390f35b81516001600160a01b038416319060609067ffffffffffffffff8111156100835761008361040a565b6040519080825280602002602001820160405280156100c857816020015b60408051808201909152600080825260208201528152602001906001900390816100a15790505b50905060005b84518110156102505760405180604001604052808683815181106100f4576100f46103f4565b60209081029190910101516040516370a0823160e01b81526001600160a01b038a81166004830152909116906370a082319060240160206040518083038186803b15801561014157600080fd5b505afa158015610155573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610179919061035a565b8152602001868381518110610190576101906103f4565b6020908102919091010151604051636eb1769f60e11b81526001600160a01b038a8116600483015288811660248301529091169063dd62ed3e9060440160206040518083038186803b1580156101e557600080fd5b505afa1580156101f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061021d919061035a565b815250828281518110610232576102326103f4565b60200260200101819052508080610248906103cb565b9150506100ce565b50935093915050565b803561026481610420565b919050565b60008060006060848603121561027e57600080fd5b833561028981610420565b925060208481013567ffffffffffffffff808211156102a757600080fd5b818701915087601f8301126102bb57600080fd5b8135818111156102cd576102cd61040a565b8060051b604051601f19603f830116810181811085821117156102f2576102f261040a565b604052828152858101935084860182860187018c101561031157600080fd5b600095505b8386101561033b5761032781610259565b855260019590950194938601938601610316565b5080975050505050505061035160408501610259565b90509250925092565b60006020828403121561036c57600080fd5b5051919050565b6000604080830185845260208281860152818651808452606087019150828801935060005b818110156103bd57845180518452840151848401529383019391850191600101610398565b509098975050505050505050565b60006000198214156103ed57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461043557600080fd5b5056fea2646970667358221220bc120b3bf50b21bf74a77b58555c773306237a35945b643c19659f4abe67f33364736f6c63430008050033

Block Transaction Difficulty 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

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

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.