Skip to content

pcaversaccio/batch-distributor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Batch Distributor

🕵️‍♂️ Test smart contracts License: MIT

Installation

It is recommended to install pnpm through the npm package manager, which comes bundled with Node.js when you install it on your system. It is recommended to use a Node.js version >= 22.0.0.

Once you have npm installed, you can run the following both to install and upgrade pnpm:

npm install -g pnpm

After having installed pnpm, simply run:

pnpm install

Unit Tests

You can run the unit tests with

pnpm test

Test Coverage

This repository implements a test coverage plugin. Simply run:

pnpm coverage

Implemented Functionalities

  • ETH Batch Transaction: distributeEther(batch (tuple))
  • ERC20 Batch Transaction: distributeToken(token (address), batch (tuple))

The parameter batch is a nested struct object that contains an array of tuples that contain each a recipient address & ETH/token amount. Please ensure that the amount for the ETH transactions is given in wei (1 wei = $10^{-18}$ ETH) and check the decimal digits for the ERC20 tokens.

{
  txns: [{ recipient: address, amount: amount }];
}

Caveats

  1. Although the batch size is only theoretically limited to the size of uint256, sending too many transactions in a batch will cause the block gasLimit to be exceeded and therefore such a transaction will revert. A large number of transactions should be split into separate batches.
  2. A low-level Solidity call will copy any amount of bytes to local memory. When bytes are copied from returndata to memory, the memory expansion cost is paid. This means that when using a standard Solidity call, the callee can "returnbomb" the caller, imposing an arbitrary gas cost. Because this gas is paid by the caller and in the caller's context, it can cause the caller to run out of gas and halt execution. It is possible to prevent this attack (see e.g. here), but this contract contains no measures against it. If you need this kind of security, please do not use this contract.

Test Deployments

The smart contract BatchDistributor has been deployed to the following test networks:

Examples

About

Helper smart contract for batch sending both native and ERC-20 tokens.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •