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-ext/provider-multicall

v6.0.0-beta.3

Published

Ethers extension for a simple multicall-based Provider to batch calls.

Downloads

560

Readme

Ethers: MulticallProvider

The MulticallProvider is designed to reduce the latency and large number of calls that can occur, especially on the initial loading of page.

This does not require any multicall contract be deployed to the network, and does not deploy any multicall contract to the network. It is only designed to assist in read-only call operations, and does not currently support sending multicall transactions.

For inspiration, see:

Installing

/home/ricmoo> npm install @ethers-ext/provider-multicall

Usage

import { MulticallProvider } from "@ethers-ext/provider-multicall";

// Create the provider which will serve as the main transport
const provider = new InfuraProvider();

// Create the multicall provider, which will aggregate calls
const multicaller = new MulticallProvider(provider);

// Connect your contracts to the multicaller
const dai = new Contract("dai.tokens.ethers.eth", daiAbi, multicaller);

// Make your multicalls
const [ sym, name, totalSupply ] = await Promise.all([
  dai.symbol(),
  dai.name(),
  dai.totalSupply(),
]);

API

new MulticallProvider(provider)

Create a new MulticallProvider using provider as the transport.

provider.queueCall(to, data) => Promise<Array<{ status: boolean, data: string }>>

Place a call into the queue to be called on the next drain. Any normal provider.call will call this internally.

provider.drainCallQueue() => Promise<void>

Regardless of the remaining time before the drainInterval, trigger all calls. This must be called explicitly when using manual drain (i.e. the drainInterval is -1).

provider.drainInterval

The drainInterval (by default, 10ms) specifies the interval to aggregate calls within. If the drainInterval is set to 0, then only calls made within a single event loop will be aggregated and if -1 is used then the provider.drainCallQueue MUST be called manually.

Pay special attention when using manual a drainInterval, as it can easily lead to deadlock, if a response is await-ed without another execution in the event loop to trigger a drain.

Contributing

If the multicall contract is changed (./contracts/multicall.sol), then you must call npm run build-solc before the changes will be added to the ./src.ts/_contract.ts file, which is a TypeScript version of the ABI and bytecode, generated using ./src.ts/_build.ts.

Please open a discussion before making any changes. :o).

Notes

This is designed for Ethers v6. For Ethers v5, see the old Multicaller.

License

MIT License.