-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
abigen
multicall support
#30217
Comments
So your feature request is to have a function aggregating the results of different calls? I don't see a big value of it. Btw, |
ether-rs (rust), viem (js), and ape (python) all support multicall out-of-the-box. People are building indexers and other data-intensive apps on top of I plan to put up a PR here updating the codegen to support multicall via the multicall3 contracts -- happy to fork if you don't want it included in the main repo. (https://www.multicall3.com/) Thanks! |
I've implemented a typed version of interacting with Multicall here for Eigen Labs (Layr-Labs/eigenpod-proofs-generation#151). Part of it relies on writing a completely deterministic deserialization function which I'll be codegenning in a fork of abigen later this weekend. Would love to upstream something here as this shows up in every Go web3 codebase i've worked in -- it's a PITA to use multicall. Then, that code can clean up to be 1-2 understandable lines on the caller side. |
I've put up a draft PR for feedback on the approach. If maintainers like the approach, I'll finish this up and we can push to merge upstream. It would be phenomenal if geth's clients / contracts supported multicall out of the box. Recent adoption of multicall lowered our querying times to the node by over 90% -- this is important for people who are writing indexers or using saas node vendors (where multicall can lower the # of node credits used over a period of time). Excited to push this forward with ya'll :) |
Rationale
Why should this feature exist?
What are the use-cases?
abigen
is a great way to interact with contracts onchain, but it doesn't (to my knowledge) support a mechanism for eth_multicall batching of requests, which makes it significantly harder to use than equivalent frameworks like Viem, which support batching via multicall already.Implementation
Do you have ideas regarding the implementation of this feature?
Are you willing to implement this feature?
multicall
variant of each function, that instead returns data on the function to execute, and then provide one general utility function that accepts avarargs
of these multicall outputs and submits them. You could also use golang generics and offer (2) and (3) bounded versions of this that are parameterized on the types of the Outputs, so that the user gets the correct struct type back in a typed tuple.Something like this for that 2->5 cases would be sufficient for me, and very nice.
References:
The text was updated successfully, but these errors were encountered: