# ERC20 batchTransfer functionality

**URL:** <https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978>\
**Category:** Support\
**Created:** [April 14, 2021, 3:14am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978 "2021-04-14T03:14:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxareo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/maxareo/32/11606_2.png) [@maxareo](https://forum.openzeppelin.com/u/maxareo)\
**Post date:** [April 14, 2021, 3:14am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/1 "2021-04-14T03:14:04Z")

</div>

Hi there, I asked this question in a telegram group a few days ago and I think it is worth being asked again here. Do you guys think it is necessary to create an ERC20 extension with a batchTransfer functionality? As the name implies, the interfaces can be:

function batchTransfer(address[.] memory recipients, uint256[.] memory amounts) public;  
function batchTransfer(address[.] memory recipients, uint256 amount) public;

This should be useful nowadays given the gas fees are increasing rapidly.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 16, 2021, 10:42am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/2 "2021-04-16T10:42:01Z")

</div>

Hi @maxareo,

It depends on the use case for the ERC20 token. Though anything which reduces the amount of gas would be good.

---

<div class="post-metadata">

**Author:** ![maxareo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/maxareo/32/11606_2.png) [@maxareo](https://forum.openzeppelin.com/u/maxareo)\
**Post date:** [April 18, 2021, 5:01am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/3 "2021-04-18T05:01:14Z")

</div>

I did some experiments and found out batchTransfer can save 5% transaction cost for 3 recipients a batch, roughly 35% for 7 recipients a batch and up to 67% for 14 recipients a batch.

```
# cost per recipient for 3 recipients
(39257 - 37187)/39257

# cost per recipient for 7 recipients
(39257 - 25583)/39257

# cost per recipient for 14 recipients
(39257 - 12970)/39257

```

The gains seem to be fairly convincing.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 19, 2021, 5:36am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/4 "2021-04-19T05:36:19Z")

</div>

Hi @maxareo,

You could also look at using Multicall: [Release Candidate for Contracts 4.1](https://forum.openzeppelin.com/t/release-candidate-for-contracts-4-1/7075)

---

<div class="post-metadata">

**Author:** ![maxareo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/maxareo/32/11606_2.png) [@maxareo](https://forum.openzeppelin.com/u/maxareo)\
**Post date:** [April 19, 2021, 7:16am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/5 "2021-04-19T07:16:32Z")

</div>

I like this abstraction, however, would there be an example walking us through a use case?

```
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
    results = new bytes[](data.length);
    for (uint i = 0; i < data.length; i++) {
        results[i] = Address.functionDelegateCall(address(this), data[i]);
    }
    return results;
}

```

Like how someone can pass input parameters and what will be returned? No example can be better than a batchTransfer of ERC20 tokens. Thanks.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 19, 2021, 7:31am UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/6 "2021-04-19T07:31:11Z")

</div>

Hi @maxareo,

Have a look at the tests for Multicall for an example:

> <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.1.0-rc.0/test/utils/Multicall.test.js#L16-L19>

---

<div class="post-metadata">

**Author:** ![popaiatx](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@popaiatx](https://forum.openzeppelin.com/u/popaiatx)\
**Post date:** [August 19, 2022, 9:47pm UTC](https://forum.openzeppelin.com/t/erc20-batchtransfer-functionality/6978/7 "2022-08-19T21:47:56Z")

</div>

Can you help me? I need to send to multiple wallets paying the lowest possible fees. I saw a transaction on BSC that paid only 2 Dollars of fee to send to 500 different wallets.  
I want to do the same but I don't know how to do it
