Why Batch Transfer?
In Web3, there is a very common need: sending funds to multiple wallet addresses in one go. For example:
- Projects airdropping tokens to N users
- Teams batch-paying salaries
- DAOs distributing rewards to community members
If you transfer one by one, it wastes time and gas. A batch transfer contract solves this.
What Can the Batch Transfer Contract Do?
The contract supports batch transfers of both native tokens (ETH / BNB) and ERC20 tokens. It also provides:
- Automatic success/failure counting
- Automatic refunds (failed amounts stored in the contract)
- Fees charged only for successful transfers
Technical Implementation
1. Data Structure
Each transfer uses a simple Transfer struct:
struct Transfer {
address to; // Recipient address
uint256 amount; // Amount (wei or token smallest unit)
}The contract accepts a Transfer[] array and processes each entry sequentially.
2. Native Token Transfer (ETH/BNB)
Uses address.call{ value: amount }("") to send native tokens.
Each transfer runs independently. On failure, the revert reason is captured and execution continues to the next; the whole batch does not roll back.
3. ERC20 Transfer
Uses SafeERC20’s transferFrom. Users must approve the contract first.
Each transfer is wrapped in try/catch; a failure does not affect others.
4. Fee and Refund Logic
Fee formula: actualFee = perAddressFee × successCount
Fees are charged only for successful transfers. Failed native amounts and any overpaid fee are returned to msg.sender in the same transaction via a native transfer at the end of the call.
FAQ
1. Is batch transfer safe? Can funds get lost?
No. The contract processes transfers one by one. If one address fails, only that transfer is affected.
Failed native amounts and unused fee are refunded to your wallet in the same transaction. If your caller cannot receive native token (e.g. some contracts), the transaction may revert. Funds are not kept on the contract for a separate withdraw step.
2. How are fees calculated?
Fees are based on address count: perAddressFee × successful transfers.
Example:
Per-address fee: 0.00002 ETH 100 addresses → 100 × 0.00002 = 0.002 ETH
⚠️ Only successful transfers are charged. Failed ones are not.
3. When do refunds arrive?
Refunds are sent to your wallet in the same transaction, after successful transfers and fee payment to the fee collector.
If the refund transfer to msg.sender fails (e.g. recipient rejects ETH), the entire batch transaction reverts.
Summary
The batch transfer contract combines multiple transfers into one on-chain transaction, saving gas and time. It supports native and ERC20 tokens, charges only for successes, and auto-refunds failures—ideal for airdrops, payroll, and rewards.