Introducing multicall for Terra

While developing dApps on Terra, it is common to make many query calls to fetch data you need, whether it be for UI display, or for further off-chain processing. To scale the dApps to support even hundreds and thousands of users, the query node can become a real a bottleneck.

With the public LCD getting hammered as Terra usage grows exponentially, and self-hosted node consuming developer’s time to scale up, we’d like to introduce a quick and easy way to optimize for RPC requests: multicall for Terra!

At SCB 10X, we believe we can grow farther if we all grow together. Today we take another step in that direction by open sourcing our multicall smart contract.

Inspired by makerdao/multicall, the entire codebase is rewritten from scratch for Terra CosmWasm, and released with Apache-2.0 license. We hope this will be useful for all LUNAtic buidlers out there!

See the code: https://github.com/scb-10x/multicall

🚚 Features

Multicall lets you perform multiple smart contract queries in a single RPC request. This lets you reduce the number of calls to the LCD node. Less stress on your node. Less round trips for your dApps!

Multicall also allows for atomic reads. One call. Multiple results. All consistent data from the same block.

🧪 Test it out

You can check our comprehensive examples at https://github.com/scb-10x/multicall#example-usage. Along each example is also a link for you to try the query out live on Bombay testnet.

📦 Usage

We’ve deployed the contracts on both testnet and mainnet. Details below:

Code ID: 3758
Contract Address: terra1y60jx2jqh5qpmcnvgz3n0zg2p6ky4mr6ax2qa5

Code ID: 53261
Contract Address: terra1z9p02s5fkasx5qxdaes6mfyf2gt3kxuhcsd4va

The contract code is available at https://github.com/scb-10x/multicall under Apache-2.0 license. Feel free to review and deploy the contract yourself!

👀 TODOs

There’s a lot more to do.

  • Javascript library for directly interacting with the multicall smart contract
  • Reduce multicall gas usage
  • Introduce other variants of the query

If you’re interested in helping out any of the above TODOs or more, feel free to submit an Github issue or pull request!

🙋 Think this is cool? Want to help?

There are many ways to spread the love forward.

  • Tag people you think should know about this tool
  • Create Github issues for bug reports and feature suggestions
  • Submit pull requests on documentations, bug fixes and new features
  • Let us know what you think by responding below or talk to us over Twitter

Thanks to Pakorn for taking the initiative in building this smart contract, and Mike for the consultation and contribution to the project!

We hope this multicall will help make dApps development on Terra easier and grow the ecosystem even more. If you have any suggestion for what you’d like to see more, feel free to let us know below or over Twitter at https://twitter.com/SCB10X_OFFICIAL.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store