Last active
June 25, 2025 14:15
-
-
Save m-waqas88/8805a9b0ccf63824ae12e735b9cdb63e to your computer and use it in GitHub Desktop.
Add Tokens to any account
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: Licensed | |
| pragma solidity 0.8.25; | |
| event MyLog(string key, uint256 val); | |
| event MyLog(string key, address val); | |
| event MyLog(string key, bytes32 val); | |
| interface IERC20 { | |
| function balanceOf(address account) external view returns (uint256); | |
| function transfer(address to, uint256 amount) external returns (bool); | |
| } | |
| function _addTokenBalance(address _account, address _token, uint256 _amount) internal { | |
| // On Ethereum Mainnet | |
| address USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; | |
| address USDC_WHALE = 0x37305B1cD40574E4C5Ce33f8e8306Be057fD7341; | |
| address USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; | |
| address USDT_WHALE = 0xF977814e90dA44bFA03b6295A0616a897441aceC; | |
| address DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F; | |
| address DAI_WHALE = 0xf6e72Db5454dd049d0788e411b06CfAF16853042; | |
| address LINK = 0x514910771AF9Ca656af840dff83E8264EcF986CA; | |
| address LINK_WHALE = 0xBc10f2E862ED4502144c7d632a3459F49DFCDB5e; | |
| address WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599; | |
| address WBTC_WHALE = 0x5Ee5bf7ae06D1Be5997A1A72006FE6C607eC6DE8; | |
| address token; | |
| address whale; | |
| if(_token == USDC) { | |
| token = USDC; | |
| whale = USDC_WHALE; | |
| }else if(_token == USDT){ | |
| token = USDT; | |
| whale = USDT_WHALE; | |
| }else if(_token == DAI){ | |
| token = DAI; | |
| whale = DAI_WHALE; | |
| }else if(_token == LINK){ | |
| token = LINK; | |
| whale = LINK_WHALE; | |
| }else if(_token == WBTC){ | |
| token = WBTC; | |
| whale = WBTC_WHALE; | |
| } | |
| vm.prank(whale); | |
| IERC20(USDC).transfer(_account,_amount); | |
| } | |
| function test_WY_tokenTransferTest() external { | |
| address waqas = makeAddr("waqas"); | |
| _addTokenBalance(waqas, 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 100000e6); | |
| console2.log(IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48).balanceOf(waqas)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment