I have this smart contract I found on github that is able to send multiple transactions but they all should be for the same token. but what I want is a smart contract that sends multiple transactions for different tokens like the picture I added, if anyone knows how let me know or send a link to a similar smart contract or project.
It would be pretty much the same as the other contract i assume, just instead of 1 token address passed or hardcoded it should accept multiple token addresses
function bulkTransfer(address _from, address _to, uint256 _amount, uint256[] memory _tokenIds) external {
for (uint256 i = 0; i < _tokenIds.length; i++) {
IERC20(_tokenIds[i]).transferFrom(_from, _to, _amount)
}
}
Please do u mind send me the complete contract, so i can deploy it in Remix and test your code.
Thanks in Advance
Try/customize the below code
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.10;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract TestItBeforeUse {
// This transfers multiple tokens from "_fromAddress" to "_toAddress".
// Make sure "formAddress" has approved all the tokens before calling "bulkTransfer"
// Make sure "_tokenAddress" and "_tokenAmount" are in same length
// Note: Here "_fromAddress" and "_toAddress" is fixed, if it is dymanic, you can make that in array
function bulkTransfer(address _fromAddress, address _toAddress, address[] memory _tokenAddress, uint[] memory _tokenAmount)
external {
for (uint256 i = 0; i < _tokenAddress.length; i++) {
IERC20(_tokenAddress[i]).transferFrom(_fromAddress, _toAddress, _tokenAmount[i]);
}
}
}
Thank you for your help with the contract for Bulk transfer.
Can we add approve function to the above code please for approve each token.
Secondly here i can see only 1 token transfer not the multiple. You can check attached image
I would like to send BUSD, Ethereum, Dai token in the same transaction to save cost.
the fromAddress must approve themselves manually.
You can also send funds to the contract and send it from the contract so that no approval is needed.
If you are interested in getting any other contract developed for you then you can message me on telegram:
@solidityX