Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
BalanceChecker
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; /////////////////////////////////////////////////////////////// // ___ __ ______ ___ __ __ ________ ______ // // /__/\ /__/\ /_____/\ /__//_//_/\ /_______/\/_____/\ // // \::\_\\ \ \\:::_ \ \\::\| \| \ \ \__.::._\/\::::_\/_ // // \:. `-\ \ \\:\ \ \ \\:. \ \ \::\ \ \:\/___/\ // // \:. _ \ \\:\ \ \ \\:.\-/\ \ \ _\::\ \__\_::._\:\ // // \. \`-\ \ \\:\_\ \ \\. \ \ \ \/__\::\__/\ /____\:\ // // \__\/ \__\/ \_____\/ \__\/ \__\/\________\/ \_____\/ // // // /////////////////////////////////////////////////////////////// /*######################### ## Interfaces ## ##########################*/ interface IERC20 { function balanceOf(address account) external view returns (uint256); function symbol() external view returns (string memory); function name() external view returns (string memory); function decimals() external view returns (uint8); } /** * @title BalanceChecker. * @dev BalanceChecker contract. * @dev This contract is used to get the token balance of an address. */ contract BalanceChecker { /*######################### ## Structs ## ##########################*/ /** * @dev Token info. * @param id The token address. * @param symbol The token symbol. * @param name The token name. * @param balance The token balance. * @param decimals The token decimals. */ struct TokenInfo { address id; string symbol; string name; uint256 balance; uint8 decimals; } /*######################### ## Read Functions ## ##########################*/ /** * @dev Get token info. * @param tokenAddress The token address. * @param owner The token owner address. */ function getTokenInfo( address tokenAddress, address owner ) internal view returns (TokenInfo memory) { TokenInfo memory tokenInfo = TokenInfo({ id: tokenAddress, symbol: "", name: "", decimals: 0, balance: 0 }); IERC20 token = IERC20(tokenAddress); try token.balanceOf(owner) returns (uint256 balance) { tokenInfo = TokenInfo({ id: tokenAddress, symbol: token.symbol(), name: token.name(), decimals: token.decimals(), balance: balance }); } catch {} return tokenInfo; } /** * @dev Get tokens balances. * @param owner The tokens owner address. * @param addresses The tokens addresses. * @return TokenInfo[] The tokens info. * @notice This function is used to get the tokens balances of an address. * @notice If the token does not implement the IERC20 interface, the token info will be empty. * @notice If the token does not implement the balanceOf function, the token balance will be 0. * @notice If the token does not implement the symbol function, the token symbol will be empty. * @notice If the token does not implement the name function, the token name will be empty. * @notice If the token does not implement the decimals function, the token decimals will be 0. */ function getBalances( address owner, address[] calldata addresses ) external view returns (TokenInfo[] memory) { TokenInfo[] memory tokenInfos = new TokenInfo[](addresses.length); for (uint256 i = 0; i < addresses.length; ++i) { tokenInfos[i] = getTokenInfo(addresses[i], owner); } return tokenInfos; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "viaIR": true, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"getBalances","outputs":[{"components":[{"internalType":"address","name":"id","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct BalanceChecker.TokenInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60808060405234610016576105e1908161001c8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c636a385ae91461002757600080fd5b34610374576040366003190112610374576004356001600160a01b03811681036103745767ffffffffffffffff80602435116103745736602360243501121561037457602435600401351161037457600590366024803560040135841b81350101116103745761009c602435600401356104d0565b906100aa60405192836104ae565b60046024350135808352601f19906100c1906104d0565b0160005b81811061040157505060005b602435600401358110610183575050604051906020808301818452825180915281604082818701971b8601019301916000955b8287106101115785850386f35b909192938280600192603f19898203018552875190848060a01b03825116815261015c61014a8484015160a0808786015284019061043b565b6040840151838203604085015261043b565b916060808201519083015260ff608080920151169101529601920196019592919092610104565b6024803582861b0101356001600160a01b0381168103610374576101a56104e8565b506040516101b281610460565b6001600160a01b03821681526040516101ca81610492565b6000815260208201526040516101df81610492565b6000815260408201526000606082015260006080820152906040516370a0823160e01b815260018060a01b038516600482015260208160248160018060a01b0386165afa600091816103cd575b50610271575b505061023e8285610515565b526102498184610515565b50600019811461025b576001016100d1565b634e487b7160e01b600052601160045260246000fd5b6040516395d89b4160e01b8152919250906000816004816001600160a01b0387165afa908115610381576000916103b2575b506040516306fdde0360e01b8152916000836004816001600160a01b0388165afa9283156103815760009361038d575b5060405163313ce56760e01b8152926020846004816001600160a01b0389165afa9283156103815760009361033b575b60ff94506040519561031487610460565b6001600160a01b031686526020860152604085015260608401521660808201523880610232565b9250926020813d602011610379575b81610357602093836104ae565b8101031261037457519260ff841684036103745760ff9392610303565b600080fd5b3d915061034a565b6040513d6000823e3d90fd5b6103ab9193503d806000833e6103a381836104ae565b81019061053f565b91386102d3565b6103c791503d806000833e6103a381836104ae565b386102a3565b9091506020813d6020116103f9575b816103e9602093836104ae565b810103126103745751903861022c565b3d91506103dc565b60209061040c6104e8565b828287010152016100c5565b60005b83811061042b5750506000910152565b818101518382015260200161041b565b9060209161045481518092818552858086019101610418565b601f01601f1916010190565b60a0810190811067ffffffffffffffff82111761047c57604052565b634e487b7160e01b600052604160045260246000fd5b6020810190811067ffffffffffffffff82111761047c57604052565b90601f8019910116810190811067ffffffffffffffff82111761047c57604052565b67ffffffffffffffff811161047c5760051b60200190565b604051906104f582610460565b600060808382815260606020820152606060408201528260608201520152565b80518210156105295760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b60208183031261037457805167ffffffffffffffff9182821161037457019082601f8301121561037457815190811161047c576040519261058a601f8301601f1916602001856104ae565b81845260208284010111610374576105a89160208085019101610418565b9056fea264697066735822122017079a6ebdb366b9ecce16c6df2135a18cc7839666b392d044b262264d30291b64736f6c63430008130033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c636a385ae91461002757600080fd5b34610374576040366003190112610374576004356001600160a01b03811681036103745767ffffffffffffffff80602435116103745736602360243501121561037457602435600401351161037457600590366024803560040135841b81350101116103745761009c602435600401356104d0565b906100aa60405192836104ae565b60046024350135808352601f19906100c1906104d0565b0160005b81811061040157505060005b602435600401358110610183575050604051906020808301818452825180915281604082818701971b8601019301916000955b8287106101115785850386f35b909192938280600192603f19898203018552875190848060a01b03825116815261015c61014a8484015160a0808786015284019061043b565b6040840151838203604085015261043b565b916060808201519083015260ff608080920151169101529601920196019592919092610104565b6024803582861b0101356001600160a01b0381168103610374576101a56104e8565b506040516101b281610460565b6001600160a01b03821681526040516101ca81610492565b6000815260208201526040516101df81610492565b6000815260408201526000606082015260006080820152906040516370a0823160e01b815260018060a01b038516600482015260208160248160018060a01b0386165afa600091816103cd575b50610271575b505061023e8285610515565b526102498184610515565b50600019811461025b576001016100d1565b634e487b7160e01b600052601160045260246000fd5b6040516395d89b4160e01b8152919250906000816004816001600160a01b0387165afa908115610381576000916103b2575b506040516306fdde0360e01b8152916000836004816001600160a01b0388165afa9283156103815760009361038d575b5060405163313ce56760e01b8152926020846004816001600160a01b0389165afa9283156103815760009361033b575b60ff94506040519561031487610460565b6001600160a01b031686526020860152604085015260608401521660808201523880610232565b9250926020813d602011610379575b81610357602093836104ae565b8101031261037457519260ff841684036103745760ff9392610303565b600080fd5b3d915061034a565b6040513d6000823e3d90fd5b6103ab9193503d806000833e6103a381836104ae565b81019061053f565b91386102d3565b6103c791503d806000833e6103a381836104ae565b386102a3565b9091506020813d6020116103f9575b816103e9602093836104ae565b810103126103745751903861022c565b3d91506103dc565b60209061040c6104e8565b828287010152016100c5565b60005b83811061042b5750506000910152565b818101518382015260200161041b565b9060209161045481518092818552858086019101610418565b601f01601f1916010190565b60a0810190811067ffffffffffffffff82111761047c57604052565b634e487b7160e01b600052604160045260246000fd5b6020810190811067ffffffffffffffff82111761047c57604052565b90601f8019910116810190811067ffffffffffffffff82111761047c57604052565b67ffffffffffffffff811161047c5760051b60200190565b604051906104f582610460565b600060808382815260606020820152606060408201528260608201520152565b80518210156105295760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b60208183031261037457805167ffffffffffffffff9182821161037457019082601f8301121561037457815190811161047c576040519261058a601f8301601f1916602001856104ae565b81845260208284010111610374576105a89160208085019101610418565b9056fea264697066735822122017079a6ebdb366b9ecce16c6df2135a18cc7839666b392d044b262264d30291b64736f6c63430008130033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.