npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

web3-transaction-batcher

v0.0.1

Published

A utility to batch Ethereum transactions

Readme

Ethereum Transaction Batcher

Build Status

A utility to batch Ethereum transactions in a single transaction.

Why use this?

  • better user experience if you need do send (or re-send) many transactions
  • save gas
  • execute a sequence of transactions as an atomic transaction - if one fails, all do

Usage

Install the package npm install ethereum-transaction-batcher.

const Web3 = require('web3')
const Batcher = require('ethereum-transaction-batcher')

// the address where the helper contrat is deployed
const batcherAddress = '0x741A4dCaD4f72B83bE9103a383911d78362611cf'
const web3 = new Web3('http://localhost:8545/') // or another ethereum provider

batcher = new Batcher({web3, batcherAddress})

// create web3 transactions as you would normally
const tx1 = myContract.myMethod(myArg1, myarg2)

// call a function on a contract
const tx2 = {
  to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
  data: '0x123454...',
}
// send some money to your friend
const tx3 =  {
  to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
  value: '1000000000000000'
}

// send the transactions as a single transaction to the blockchain
// the batched transaction will fail if one of the subtransactions fail
const receipt = await batcher.sendTransaction([tx1, tx2, tx3])
console.log(receipt.events)

API

const batcher = new Batcher({
  web, // web3 instance, required
  batcherAdddress // address of batcher contract, optional if the network is main or rinkeby
})

A Batcher instance exposes a fucntion sendTransaction. The signature and behavior of the function is similar to the sendTransaction method in web3.js - the function can be called by providing it with a callback, if the callback is omitted it will return a Promise - but instead of taking a single transaction object as its first argument, it takes a list of transactions.

batcher.sendTransaction(
  transactions, // a list of web3-style transaction objects
  callback // optional, like in web3.js
)

The batcher.sendTransaction call will try to execute the entire list of transactions in the order that they are given. If one of them fails, the batched transaction fails atomically - i.e.\ none of the transactions will be executed.

sendTransaction behaves like web3.eth.sendTransaction - if a callback is provided, it will be called, if no callback is provided, it will return a promise that resolves to a transaction receipt.

The Contract

The solidity code is here.

Limitations

  • The batched transactions will be sent from the Batcher contract - which means that transactions that require msg.sender to be (say) the account with which the batched transaction is signed, will fail. However, the batcher will work when for sending Ether in batch transactions.
  • The batcher contract can only cal functions on existing contracts - it does not create new contracts

TODO

  • use assembly call to save gas
  • use assembly create to also allow for contract creation
  • forward tokens, so that one can batch-send tokens as well as Ether

License

GNU GPL