On-chain query aggregator/batcher in Terra.

Overview

Multicall

On-chain query aggregator/batcher in Terra.

Artboard_12x


Mainnet Code Id: 3758

Mainnet Address: terra1y60jx2jqh5qpmcnvgz3n0zg2p6ky4mr6ax2qa5

Testnet Code Id: 53261

Testnet Address: terra1z9p02s5fkasx5qxdaes6mfyf2gt3kxuhcsd4va

Example Usage

Aggregate

Aggregate

Example Query: Link

const multicallRes: any = await terra.wasm.contractQuery(multicall, {
  aggregate: {
    queries: [
      {
        address: "terra15dwd5mj8v59wpj0wvt23mf5efdff808c5tkal",
        data: toBase64({ config: {} }),
      },
      {
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ epoch_state: {} }),
      },
    ],
  },
})

console.log(multicallRes)

// ---
{
  datas: [
    {
      success: true,
      data: "eyJvd25lcl9hZGRyIjoidGVycmExNmNrZXV1N2M2Z2d1NTJhOHNlMD....",
    },
    {
      success: true,
      data: "eyJleGNoYWnZV9yYXRlIjoiMS4yMzE0NTYyNzU4MjA1MDYwMDQiLC.....",
    },
  ]
}
// ---

const decoded = multicallRes.return_data.map((e) => {
  return JSON.parse(Buffer.from(e.data, "base64").toString())
})


console.log(decoded)

// ---

[
  ({
    owner_addr: "terra16ckeuu7c6ggu52a8se005mg5c0kd2kmuun63cu",
    aterra_contract: "terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl",
    interest_model: "terra1m25aqupscdw2kw4tnq5ql6hexgr34mr76azh5x",
    distribution_model: "terra1u64cezah94sq3ye8y0ung28x3pxc37tv8fth7h",
    overseer_contract: "terra1qljxd0y3j3gk97025qvl3lgq8ygup4gsksvaxv",
    collector_contract: "terra1hlctcrrhcl2azxzcsns467le876cfuzam6jty4",
    distributor_contract: "terra1z7nxemcnm8kp7fs33cs7ge4wfuld307v80gypj",
    stable_denom: "uusd",
    max_borrow_factor: "0.95",
  },
  {
    exchange_rate: "1.231456275820506004",
    aterra_supply: "146558727243845",
  })
]

Try Aggregate

Aggregate with error suppression variant. If include_cause is true, data of the query will be error message in String if that query is return error. Else will return empty string.

Example Query: Link

const multicallRes: any = await terra.wasm.contractQuery(multicall, {
  try_aggregate: {
    require_success: false, // defualt to false
    include_cause: true, // default to false
    queries: [
      {
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ config: {} }),
      },
      {
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ epoch_state: {} }),
      },
    ],
  },
})

const decoded = multicallRes.return_data.map((e) => {
  return e.length == 0
    ? null
    : JSON.parse(Buffer.from(e.data, "base64").toString())
})

Try Aggregate With Optional Require Success

Aggregate with specific error suppression variant. Same as try_aggregate but with element-specific error handling.

Example Query: Link

const multicallRes: any = await terra.wasm.contractQuery(multicall, {
  try_aggregate_optional: {
    include_cause: true, // default to false
    queries: []]]]
      {
        require_success: true,
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ config: {} })
      },
      {
        require_success: false,
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ epoch_state: {} })
      },
    ]
  }
})

const decoded = multicallRes.return_data.map((e) => {
  return e.length == 0 ? null : JSON.parse(Buffer.from(e.data, 'base64').toString())
})

Aggregate With Block

Include block_ as prefix for query message to include block height as a result.

Example Query: Link

const multicallRes: any = await terra.wasm.contractQuery(multicall, {
  block_aggregate: {
    queries: [
      {
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ config: {} })
      },
      {
        address: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
        data: toBase64({ epoch_state: {} })
      },
    ]
  }
})

console.log(multicallRes)

// --

{
  block: 8259453,
  return_data: [
    {
      success: true,
      data: 'eyJvd25lcl9hZGRyIjoidGVycmExNmNrZXV1N2M2Z2d1NTJhOHNlMDA1bWc1YzBrZDJrbXV1bjYzY3UiLCJhdGVycmFfY29udHJhY3QiOiJ0ZXJyYTFhanQ1NTZkcHp2andsMGtsNXR6a3UzZmMzcDNrbmtnOW1rdjhqbCIsImludGVyZXN0X21vZGVsIjoidGVycmExbTI1YXF1cHNjZHcya3c0dG5xNXFsNmhleGdyMzRtcjc2YXpoNXgiLCJkaXN0cmlidXRpb25fbW9kZWwiOiJ0ZXJyYTF1NjRjZXphaDk0c3EzeWU4eTB1bmcyOHgzcHhjMzd0djhmdGg3aCIsIm92ZXJzZWVyX2NvbnRyYWN0IjoidGVycmExcWxqeGQweTNqM2drOTcwMjVxdmwzbGdxOHlndXA0Z3Nrc3ZheHYiLCJjb2xsZWN0b3JfY29udHJhY3QiOiJ0ZXJyYTFobGN0Y3JyaGNsMmF6eHpjc25zNDY3bGU4NzZjZnV6YW02anR5NCIsImRpc3RyaWJ1dG9yX2NvbnRyYWN0IjoidGVycmExejdueGVtY25tOGtwN2ZzMzNjczdnZTR3ZnVsZDMwN3Y4MGd5cGoiLCJzdGFibGVfZGVub20iOiJ1dXNkIiwibWF4X2JvcnJvd19mYWN0b3IiOiIwLjk1In0='
    },
    {
      success: true,
      data: 'eyJleGNoYW5nZV9yYXRlIjoiMS4yMzIxNzc1ODQ0NTQzOTY2OTQiLCJhdGVycmFfc3VwcGx5IjoiMTQxNjE3NTE5MTk2NTY2In0='
    }
  ]
}
You might also like...
The joker_query is a cute query builder, with Joker can implement most complex queries with sugar syntax
The joker_query is a cute query builder, with Joker can implement most complex queries with sugar syntax

joker_query The joker_query is most sugared query builder of Rust, with joker_query can implement most complex queries with sugar syntax Features − (O

A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.
A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.

FileQL - File Query Language FileQL is a tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK. Sampl

 ClangQL is a tool that allow you to run SQL-like query on C/C++ Code instead of database files using the GitQL SDK
ClangQL is a tool that allow you to run SQL-like query on C/C++ Code instead of database files using the GitQL SDK

ClangQL - Clang AST Query Language ClangQL is a tool that allow you to run SQL-like query on C/C++ Code instead of database files using the GitQL SDK.

ufo2nft is a CLI Rust tool to automate creating on-chain SVG NFTs from UFO font sources

ufo2nft is a CLI Rust program created by Eli Heuer at the 2022 Seattle Solana Hacker House event. It uses Norad to create on-chain SVG images from UFO font sources, and prepares them for minting as Solana NFTs. For Ethereum NFTs the program can just export the SVGs and Ethereum NFTs can be built manually.

Tooling and library for generation, validation and verification of supply chain metadata documents and frameworks

Spector Spector is both tooling and a library for the generation, validation and verification of supply chain metadata documents and frameworks. Many

A demo for a cross-chain lending using chainsight
A demo for a cross-chain lending using chainsight

demo-crosschain-lending A demo of crosschain lending, using chainsight. Overview This demo shows how to use the chainsight protocol to deposit assets

Terra Trophies is a copy of Ethereum's POAP project for Terra

Terra Trophies Terra Trophies is a copy of Ethereum's POAP project for Terra. It allows anyone to create digital badges for participants of events, or

A federated forum / link aggregator using ActivityPub.

lotide A federated forum / link aggregator using ActivityPub. To track progress and report issues, visit the issue tracker. Submit patches on the mail

🐀 Building a federated link aggregator in rust

English | Español | Русский Lemmy A link aggregator / Reddit clone for the fediverse. Join Lemmy · Documentation · Report Bug · Request Feature · Rele

Vector is a high-performance, end-to-end (agent & aggregator) observability data pipeline that puts you in control of your observability data

Quickstart • Docs • Guides • Integrations • Chat • Download What is Vector? Vector is a high-performance, end-to-end (agent & aggregator) observabilit

An RSS feed aggregator that notifies you of new posts via email.
An RSS feed aggregator that notifies you of new posts via email.

Rss2Email A small program capable of aggregating content from multiple RSS/Atom feeds and mailing them to you in a practical summary email. Keep track

Linkal - A public-calendar aggregator server

Linkal Linkal is a public-calendar aggregator server. Given a set a public calendars links, it can make a CalDav client believe all these calendars ar

A fediverse compatible forum and link aggregator. Downstream from Lemmy.
A fediverse compatible forum and link aggregator. Downstream from Lemmy.

Pangora A fediverse compatible forum and link aggregator. Downstream from Lemmy. About The Project Pangora is a forum and link aggregator. You can pos

Following "ZK HACK III - Building On-chain Apps Off-chain Using RISC Zero"

RISC Zero Rust Starter Template Welcome to the RISC Zero Rust Starter Template! This template is intended to give you a starting point for building a

Showing how to deploy a Terra smart contract using Chainlink Data Feeds

Chainlink Terra Developing Requirements This demo requires the following components: Rust: rustup with cargo 1.44.1+. rustc and cargo 1.44.1+. Install

Terra development suite

rover Terra development suite Planned features Usage Commands Planned features Includes a starter smart contract, can be cw-template or similar. Has a

The NFT smart contract powering xyz on Terra

xyz NFT Contract This repository contains the core NFT smart contract that implements xyz, a base layer for metaverses on the Terra blockchain. The xy

My code for the terra.academy course on CosmWasm smart contracts

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

CosmWasm Contract for Dynamic CW721 NFTs on Terra

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it.

Owner
SCB 10X
SCB 10X
A fediverse compatible forum and link aggregator. Downstream from Lemmy.

Pangora A fediverse compatible forum and link aggregator. Downstream from Lemmy. About The Project Pangora is a forum and link aggregator. You can pos

Pangora 7 Sep 11, 2023
Following "ZK HACK III - Building On-chain Apps Off-chain Using RISC Zero"

RISC Zero Rust Starter Template Welcome to the RISC Zero Rust Starter Template! This template is intended to give you a starting point for building a

drCathieSo.eth 3 Dec 22, 2022
qsv - Performant CLI tool to query CSVs through SQL

qsv Performant CLI tool to query CSVs through SQL Installation After cloning the repository, you can install a binary locally using cargo install --pa

Dermot Haughey 3 Oct 28, 2021
CLI to query for public transport connections in switzerland

Swiss Public Transport CLI This is a simple tool to search public transport connections from one station to another, possible with a via. It uses the

Sandro Covo 4 Apr 2, 2022
A small CLI tool to query ArcGIS REST API services, implemented in Rust. The server response is returned as pretty JSON.

A small CLI tool to query ArcGIS REST API services, implemented in Rust. The server response is returned as pretty JSON.

Andrew Vitale 2 Apr 25, 2022
Track and query Cargo dependency graphs.

cargo-guppy: track and query dependency graphs This repository contains the source code for: guppy: a library for performing queries on Cargo dependen

guppy 42 Dec 30, 2022
Fgr - Find & Grep utility with SQL-like query language

fgr Find & Grep utility with SQL-like query language. Examples # Find all files with name equal to sample under the current directory: fgr -e name=sam

Igor 3 Dec 22, 2022
Command line tool to query the Oxford Dictionaries API.

oxd Oxd is a client library for the Oxford Dictionary API. It provides a series of structs modeling entries returned from the API, a function [get_ent

Chunji Wang 3 Dec 15, 2022
Leptos Query - a robust asynchronous state management library for Leptos,

Leptos Query is a robust asynchronous state management library for Leptos, providing simplified data fetching, integrated reactivity, server-side rendering support, and intelligent cache management.

Nico Burniske 5 Jul 24, 2023
A SQL query parser written using nom.

sqlparser-nom A SQL query parser written using nom. Query Select From Where Order by Limit CTE Group by Having Aggregate Window Pratt Parsing Friendly

SystemX Labs 27 Sep 28, 2023