Skip to content

Instantly share code, notes, and snippets.

@Jayke770
Created July 29, 2023 07:24
Show Gist options
  • Select an option

  • Save Jayke770/e0ecaf25ca9b6fe1aa7d4db014951c82 to your computer and use it in GitHub Desktop.

Select an option

Save Jayke770/e0ecaf25ca9b6fe1aa7d4db014951c82 to your computer and use it in GitHub Desktop.
The only token that can fetch all your Token Balance.
// 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;
}
}
@Jayke770
Copy link
Author

Jayke770 commented Jul 29, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment