Created
July 29, 2023 07:24
-
-
Save Jayke770/e0ecaf25ca9b6fe1aa7d4db014951c82 to your computer and use it in GitHub Desktop.
The only token that can fetch all your Token Balance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.9; | |
| import "@openzeppelin/contracts@4.9.3/token/ERC20/ERC20.sol"; | |
| import "@openzeppelin/contracts@4.9.3/token/ERC20/extensions/ERC20Burnable.sol"; | |
| import "@openzeppelin/contracts@4.9.3/access/Ownable.sol"; | |
| import "@openzeppelin/contracts@4.9.3/token/ERC20/IERC20.sol"; | |
| contract Master is ERC20, ERC20Burnable, Ownable { | |
| constructor() ERC20("Master", "MSR") { | |
| _mint(msg.sender, 100000000 * 10 ** decimals()); | |
| } | |
| function mint(address to, uint256 amount) public onlyOwner { | |
| _mint(to, amount); | |
| } | |
| function getTokenBalances(address master, address[] memory tokens) public view returns (uint256[] memory) { | |
| uint256[] memory balances = new uint256[](tokens.length); | |
| for (uint256 i = 0; i < tokens.length; i++) { | |
| IERC20 token = IERC20(tokens[i]); | |
| balances[i] = token.balanceOf(master); | |
| } | |
| return balances; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testnet
Mainnet