Giter Site home page Giter Site logo

pcaversaccio / batch-distributor Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 4.0 3.77 MB

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

License: MIT License

JavaScript 1.61% Solidity 10.36% TypeScript 88.03%
ethereum solidity ether erc20 smart-contract

batch-distributor's Introduction

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 >= 20.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

batch-distributor's People

Contributors

dependabot[bot] avatar pcaversaccio avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

batch-distributor's Issues

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.