makerdao / multicall.js

Multicall.js: A JavaScript blockchain state management library for dapps
MIT License
421 stars 97 forks source link

Why use multicall.js instead of web3.js? #17

Open wjmelements opened 4 years ago

wjmelements commented 4 years ago

There's no advantage of using your smart contract vs regular jsonrpc batching. In fact the performance is worse.

Get the return value(s) of multiple smart contract function calls in a single call

This is not superior to using a batch because the batch is in parallel.

Guarantee that all values are from the same block

You can specify a block number in the call. Polling "latest" results in unnecessary calls since you should only poll when you get a new block. A block is already a snapshot.

Use watchers to poll for multiple blockchain state variables/functions Get updates when a watcher detects state has changed Results from out of sync nodes are automatically ignored Get new block updates

These are valid and useful, but don't require the batch contract.