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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ethers-multisend-package

v1.0.15

Published

A package to handle multi-send transactions on Ethereum.

Downloads

18

Readme

Ethers Multisend Package

The ethers-multisend-package enables the execution of batch transactions on the Ethereum network utilizing the ethers.js library. This package supports batching operations for Ether, ERC20 tokens, and generic function calls. It also includes utilities for token allowance checks, approvals, and gas estimation.

Installation

To use this package, first install it via npm:

npm install ethers-multisend-package

Configuration

Before using the batch execution functions, create a config file for ease of use and configure the network and contract details:

import { ethers } from 'ethers';

interface Config {
  networkUrl: string;
  contractAddress: string;
}

const config: Config = {
  networkUrl :   "https://virtual.mainnet.rpc.tenderly.co/8c916c79-0c6d-4245-b325-447fb811862e",
  contractAddress: '0xCD4030d7e7Cb295D3f227A175DBa01dD1988F45B',
};

const provider = new ethers.JsonRpcProvider(config.networkUrl);

export { config, provider };

Note: You can deploy your own contract and replace the contract address with your own or use the one provided in the config.ts file.

Usage

Check out example

To execute batch transactions, prepare an array of transactions, a signer, and optionally, gas options. Use the following function to execute them:

function executeBatchTransactions(
  transactions: Transaction[], 
  signer: ethers.Signer,  
  gasOptions?: GasOptions
): Promise<ethers.TransactionResponse> {}

Transaction arry look like this


interface Transaction {
  type: "ETH" | "ERC20";
  to: string;
  amount: string;
  tokenAddress?: string;
  decimals?: number;
}

Allowance Manager

For checking allowance, approvance you can use our setTokenAllowance and checkTokenAllowance functions respectively

export async function setTokenAllowance(tokenAddress: string, amount: string, signer: ethers.Signer): Promise<void> {}
export async function checkTokenAllowance(tokenAddress: string, ownerAddress: string, signer: ethers.Signer): Promise<string> {}

Gas Estimation

Gas estimation is handled by the estimateGas function in the gasEstimation.ts file. You can use it by providing the signer and transaction request:

import { estimateGas } from './gasEstimation';

const estimatedGas = await estimateGas(signer,transactionRequest);

Example

Here is an example of how you can use the package to execute batch transactions:

const transactions = [
  {
    type: "ETH",
    to: "0x1234567890abcdef1234567890abcdef12345678",
    amount: "0.5",
  },
  {
    type: "ERC20",
    to: "0xabcdef1234567890abcdef1234567890abcdef12",
    amount: "100",
    tokenAddress: "0xdeadbeef1234567890abcdef1234567890abcdef",
    decimals: 18
  }
];

const signer = new ethers.Wallet('<privateKey>', provider);

or

const signer = new ethers.BrowserProvider(window.ethereum);

const gasOptions = {
  gasPrice: ethers.parseUnits('10', 'gwei'),
  gasLimit: 1000000
};

if you dont give gasOptions it will be estimated automatically by 
const estimatedGasLimit = await estimateGas(signer,transactionRequest); 



const estimatedGas = await estimateGas(signer,transactionRequest);

const result = await executeBatchTransactions(transactions, signer, gasOptions);

Ensure that you have the necessary allowance in case of token give to contract and balance to execute the transactions on the Ethereum network.