I am newbie to the smart contract development & have developed a smart contract that can transfer ERC20 tokens to multiple addresses in single transaction. I test it by creating new Tokens & it works.
However i have been using USDC Token for quite long time https://rinkeby.etherscan.io/address/0x83cb1597cf92f0a492be26311fd88d08cab53859 when i try to use that token to transfer USDC to some addresses the transaction fails with error execution reverted
sample transaction : https://rinkeby.etherscan.io/tx/0xb072684709e11d3c18db61f2ca7e9e5432cef00b790fb2e38f3acd8258c9ed56
main functions in my contract are
/**
* @dev sends a internal transaction based on the currency specified in the
* parameters, it use the ERC20 interface for currencies stored in the contracts
* map
*/
function withdrawalERC (IERC20 token, address _client, uint256 _amount) private {
require(_client != address(0), "address needs to be given");
require(_amount > 0, "amount needs to be greater than 0");
require(token.balanceOf(address(this)) >= _amount, "not enough token funds to send transaction");
token.transfer(_client, _amount);
}
/**
* @dev sends multiple internal transactions based on the currency specified in the
* parameters, check "withdrawalERC" for more details, this method just handles the parameters list
*/
function batchWithdrawalERC(address token_addr, address[] calldata _clients, uint256[] calldata _amounts) external onlyOwner {
require(_clients.length == _amounts.length, "address, amount array length need to be equal");
require(token_addr != address(0), "invalid contract address");
IERC20 iERC20 = IERC20(token_addr);
for (uint16 i=0; i < _clients.length; i++) {
withdrawalERC(iERC20, _clients[0], _amounts[0]);
}
}
My questions are
- Is the logic good enough to perform batch transfer ?
- How can i deploy ERC20 token e. g USDC that is more close to mainnet USDC token? or even if its is possible ?
Any guidance would be much appreciated