Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multicaller

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multicaller

Efficient multicaller contract

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
increased by59.09%
Maintainers
1
Weekly downloads
 
Created
Source

Multicaller

NPM CI MIT License

Efficiently call multiple contracts in a single transaction.

Allows for optional "forwarding" of msg.sender to the contracts called.

Deployments

ChainMulticaller
Ethereum0x00000000000015bF55A34241Bbf73Ec4f4b080B2
Goerli0x00000000000015bF55A34241Bbf73Ec4f4b080B2
Polygon0x00000000000015bF55A34241Bbf73Ec4f4b080B2
Mumbai0x00000000000015bF55A34241Bbf73Ec4f4b080B2
Optimism0x00000000000015bF55A34241Bbf73Ec4f4b080B2
Arbitrum0x00000000000015bF55A34241Bbf73Ec4f4b080B2

Please open an issue if you need help to deploy to an EVM chain of your choice.

Contracts

src
├─ Multicaller.sol — "The multicaller contract"
└─ MulticallerReader.sol — "Library to read the `msg.sender` of the multicaller contract"

Installation

You can use the src/MulticallerReader.sol library in your contracts to query the Multicaller efficiently.

To install with Foundry:

forge install vectorized/multicaller

To install with Hardhat or Truffle:

npm install multicaller

API

Multicaller

aggregate
function aggregate(address[] calldata targets, bytes[] calldata data)
    external
    payable
    returns (bytes[] memory)

Aggregates multiple calls in a single transaction.

The msg.value will be forwarded to the last call.

aggregateWithSender
function aggregateWithSender(address[] calldata targets, bytes[] calldata data)
    external
    payable
    returns (bytes[] memory)

Aggregates multiple calls in a single transaction.

The msg.value will be forwarded to the last call.

This method will set the multicaller sender to the msg.sender temporarily for the span of its execution.

This method does not support reentrancy.

fallback
fallback() external payable

Returns the address that called aggregateWithSender on the contract.

The value is always the zero address outside a transaction.

MulticallerReader

Library to read the msg.sender of the multicaller contract.

multicallerSender
function multicallerSender() internal view returns (address)

Returns the address that called aggregateWithSender on the multicaller.

sender
function sender() internal view returns (address result)

Returns the address that called aggregateWithSender on the multicaller, if msg.sender is the multicaller.

Otherwise, returns msg.sender.

Design

The contracts are designed with a priority on efficiency and minimalism.

  • Multiple input calldata arrays instead of an array of structs for more compact calldata encoding.

  • Omission of utility functions like getBlockNumber for more efficient function dispatch. If you need those functions, just add those functions into your contract, or read them off a separate utility contract like MakerDao's Multicall.

Safety

We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.

Acknowledgments

Multicaller is inspired by and directly modified from:

This project is a public good initiative of sound.xyz and Solady.

We would like to thank our reviewers and contributors for their invaluable help.

FAQs

Package last updated on 16 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc