Hello, I have been struggling for days now trying to figure this out so any tips would be highly appreciable.
I am attempting to batch transfer tokens to an array of addresses with a function like this:
function batchTransferToken(address[] memory holders, uint256 amount) public payable {
for (uint i=0; i<holders.length; i++) {
emit Transfer(address(this), holders[i], amount);
}
}
The transaction is successful but the token simply does not move to target wallet addresses. I have made sure contract has required tokens for transfer.
Here is example transaction:
I have seen other people use this exact function successfully but it does not work for me.
If I replace:
emit Transfer(address(this), holders[i], amount);
with :
_transfer(_msgSender(), holders[i], amount);
It works if I use _transfer but then the batch transfer is prohibitively expensive.
I understand that emit Transfer is an event and the _transfer is a function but I have seen others use emit Transfer to move tokens without calling _transfer.
I have seen other people batch transfer tokens with this method as cheap as 4000 tokens at $36 so this is the goal.
Thanks in advance for any suggestions.