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

v3.1.0

Published

A package for crafting multi-send transaction from a Zodiac Avatar, such as a Safe, based on ethers.js

Downloads

12,978

Readme

ethers-multisend

Build Status Contributor Covenant

An npm package for crafting multi-send transaction from a Safe, based on ethers.js v5.

Features

  • Easily encode the most common types of transactions from JSON inputs:
    • ETH & ERC20 token transfers
    • NFT transfers
    • Contract function calls
    • Raw transactions
  • Encode a batch of transactions into a single multi-send call.

What to do with the encoded transaction objects?

The encode functions produce JavaScript objects that can be used to actually execute the described transactions. There are various ways to do that, using direct calls to your Safe contract, or by relaying it using the infrastructure provided by Safe. Check out the Safe{Core} SDK to learn more: https://github.com/safe-global/safe-core-sdk

Installation

This module is distributed via npm. For adding it to your project, run:

npm install --save ethers-multisend

To install it using yarn, run:

yarn add ethers-multisend

API

encodeSingle

encodeSingle(transactionInput: TransactionInput): MetaTransaction

Encodes a single transaction input and turns into an format that is ready for execution.

encodeMulti

encodeMulti(
  metaTransaction: MetaTransaction[],
  multiSendContractAddress?: string
): MetaTransaction

Batches a set of meta transactions into a single multi-send contract call.

You can optionally provide the multiSendContractAddress to use. By default, it will use MultiSendCallOnly v1.4.1 or MultiSend v1.4.1 if the batch includes any delegate calls.

decodeSingle

decodeSingle(
  metaTransaction: MetaTransaction,
  provider: Provider,
  fetchAbi?: (address: string) => Promise<string | undefined>,
  id?: string
): Promise<TransactionInput>

Decodes a meta transaction and returns a transaction input object of one of the four supported types. It needs an ethers provider instance to fetch decimals for ERC20 token transfers, and a function for fetching the ABI for a contract address.

decodeMulti

decodeMulti(data: string): MetaTransaction[]

Given the data string of a multi-send transaction, returns an array of the included meta transactions.

createTransaction

createTransaction(type: TransactionType, id?: string): TransactionInput

Creates an empty transaction input of the specified type.

isValid

isValid(transactionInput: TransactionInput): boolean

Returns whether the provided transaction input can be encoded into a meta transaction without errors and has a valid to address.

Types

The TransactionInput type captures the information for any of the four supported transaction types.

type TransactionInput =
  | CallContractTransactionInput
  | TransferFundsTransactionInput
  | TransferCollectibleTransactionInput
  | RawTransactionInput

The library's encoding functions return objects of the MetaTransaction type, which is a format with an ABI encoded data field so it is ready for execution.

interface MetaTransaction {
  readonly to: string
  readonly value: string
  readonly data: string
  readonly operation?: OperationType
}

Find the full information about all TypeScript types here: src/types.ts