Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicall support #788

Closed
Destiner opened this issue Apr 17, 2020 · 6 comments
Closed

Multicall support #788

Destiner opened this issue Apr 17, 2020 · 6 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@Destiner
Copy link

As projects usually make a lot of queries per page (and Infura call limits are quite modest), I think it might be a good idea to support multicall.

There is multicall.js, but its pretty low-level (and in general have a different approach to ethereum querying).

There is also ethcall (which is kind of multicall and ether.js baby), but given that it's already tightly coupled with ethers, I think it might be a good idea to have this functionality without an additional dependency.

@ricmoo
Copy link
Member

ricmoo commented Apr 17, 2020

I’ve thought about adding a similar batching for token and ether balances. It’s an interesting idea, and I think the easiest and most useful way would be to add a new provider, which can be backed by any other provider, and have a short delay (maybe 10ms; configurable) queueing up requests and then sending them all at once (or in blocks) to the contract.

Then it just works, no code changes needed and handles the common case where a bunch of calls are made in the same event loop, and also doesn’t hold up the dependency graph.

I’ll look into it over the weekend and probably add it to the experimental package to try out before adding it to the provider package.

Thanks for the suggestion. :)

@ricmoo ricmoo added enhancement New feature or improvement. next version (v5) on-deck This Enhancement or Bug is currently being worked on. labels Apr 17, 2020
@jparklev
Copy link

jparklev commented May 5, 2020

Ooh hah, so I think @michaelelliot was working on basically exactly this just the other week as an experiment. I don't have too much to add to the idea, other than to say that it sounds great, but I thought it was exciting/ a positive sign/ serendipitous that there was independent alignment

@PfanP
Copy link

PfanP commented Feb 8, 2021

Hey, why batch call is still not added to ethers?

@ricmoo
Copy link
Member

ricmoo commented Feb 8, 2021

@self-coding-crab batch calls are unrelated to multicalls.

It turns out multicall has an issue with certain opcodes that need work around for, which I’m hoping to address later in v6 with a new type of provider.

Batch calls are not available yet, because they add very little value, are less performant and not all backends support them. It is important to note that batch calls are part of the JSON-RPC specification, nothing specific to Ethereum or Geth.

There are plenty of issues you can search though for more details (e.g. #62), and I plan to add a cookbook entry on how to create an implicit batching provider, but there has not been many strong arguments made in favour of batching; I’m more than welcome to hear thoughts though. Perhaps start a new discussion?

But this issue is specifically for multicall (not batching).

Does that all make sense? :)

@PfanP
Copy link

PfanP commented Feb 8, 2021

Thanks for your reply @ricmoo . I've already checked all GitHub issues explaining batch calls.
#62 (comment)
Is it what web3 BatchRequest does?
I thought batch call chunk txs into one block to optimize gas

@ricmoo
Copy link
Member

ricmoo commented Aug 31, 2024

Cleaning up some older issues.

Ethers v6 fully supports batching internally and the MulticallProvider package has full multicall support.

Let me know if some aspect of this issue is still not addressed.

Thanks! :)

@ricmoo ricmoo closed this as completed Aug 31, 2024
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

4 participants