-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Equivalent to web3 BatchRequest? #656
Comments
There is not. :) You may already know this, but I will expand a bit here for others that happen across this issue in the future. :) There is often a misunderstanding of what batching does in JSON-RPC (it is part of the JSON-RPC specification more so than anything to do with Ethereum). A batch request of A and B will always take longer than the requests A and B made at the same time, as batching is designed to ensure serial execution, therefore has a negative effect on performance in a system which only offers eventual consistency anyways. Batching is not without its uses, but its use is limited and is specific only to certain backends and usually requires a more complex API that is only compatible with those backends. It can be used using the lower level It also does not address consistency, since even if two transactions are sent and accepted by the network in some order, it is not certain they will be mined in that order. Ensuring order with proper nonce management is the only way to guarantee consistency. Feel free to convince me otherwise though, if you have a compelling reason to add support for it. :) |
Agree, it's only my second time looking at batching many requests. Our use case is to batch send several transactions via a CSV loaded into a back office tool. Not a biggy, I can work around it manually i think. Thanks for the mega quick and solid response as well 👍 |
I'm going to close this now (I think the question is resolved?), but please feel free to re-open if you have more questions. Or continue commenting as I monitor closed issues. Thanks! :) |
Just wanted to mention that unless I am mistaken there are probably some use cases for batch requests from an optimisation point of view, especially when making many requests at the same time. The main benefit isn't necessarily in publishing transactions, but for reading data; consider that you want read 1000 entries from a contract. Yes, you could make 1000 separate http requests, but this could be made more efficient by batching:
|
UX wise aka read-only I agree it could be nice to have a batch feature. MakerDao came up with an interesting solution https://github.com/makerdao/multicall.js however it's based on a multicall smart contract to aggregate the calls. |
never mind I just found #788 |
There is a multicall-based Provider in the works. :) |
So is there any solution for batch call? |
I've added |
Hi @ricmoo. I misunderstood your words:
You are talking that we need to manage order of transactions through nonce. But as I know I'm sending transaction to provider already with nonce. |
@yanikitat Yes, that is true if from the same account. The issue is consistency, where tx1 is sender A sends B an NFT and tx2 is sender B sends that NFT to C. As long as tx1 happens before tx2, all is good. But if tx2 happens first (they are different from accounts, so their nonce is independent) then B is trying to send an NFT they do not get own, and the tx will fail. So, the order of the transactions matter And depending which is mined first, will result in very different outcomes. Does that make sense? |
Thanks a lot @ricmoo!! I didn't think about the different accounts. It make sense of course |
Hi guys, just wondering if there is a etherejs equivalent to BatchRequest in webjs?
My current thoughts I can manually do this by maintaining the correct nonce value between each submission.
The text was updated successfully, but these errors were encountered: