SubQuery Example Project — fetch.ai

SubQuery Network
4 min readDec 4, 2023

In this article, we aim to provide a more detailed overview of Fetch.ai, the integration of which we previously announced. Fetch.ai stands as a beacon of innovation by establishing an open-access, tokenised, and decentralised machine learning network, fostering the development of intelligent infrastructure within a decentralised digital economy. The setup of an indexer for the FetchAI is a pivotal step for those interested in exploring the synergy between the dynamic realm of Web3 and AI.

Our goal is to demystify the entire process, making it accessible to users of all skill levels. Whether you are an experienced developer or just beginning your journey into the world of Web3, this guide equips you with the knowledge and confidence necessary to smoothly navigate the FetchAI Protocol ecosystem and its primary components.

Example

The sample project from FetchAI collects a vast number of entities. The schema describes various entities and their relationships within the blockchain network, allowing developers to query and index data related to blocks, transactions, messages, events, contracts, and more. Here’s a brief description of some key entities in the schema:

  • Entities such as `Block`, `Transaction`, `Message`, `Event`, `ExecuteContractMessage`, and others represent fundamental components of blockchain data. They include details like block height, timestamps, gas usage, and related data.
  • The `Contract` entity represents smart contracts deployed on the blockchain.
  • Entities like `NativeTransfer` and `Cw20Transfer` represent transfers of native and CW20 (a custom token standard) tokens, including sender and recipient addresses, amounts, and related information.
  • `Account` stores information about user accounts, including their balances and other related data.
  • `AuthzExec` and `AuthzExecMessage` entities are used for authorization execution of specific operations and messages.
  • `Almanac` related entities appear to be related to an almanac service and its registration.
  • `GovProposalVoteOption` and `TxStatus` are enums representing different options for governance proposal votes and transaction statuses, respectively.

Key resources:

Use-Cases

Upon running the project, you have the capability to pose questions. Given that all entities, such as ‘Block,’ ‘Transaction’, ‘Event’, and ‘Message’ are interconnected, you can obtain answers to your inquiries with a single question. This functionality is illustrated in the following example:

You can utilise the following request to query various types of transfers within a single query. Note that we have the capability to set a limit on the number of results to retrieve for each entity.

Given that this project involves data related to governance, we can also gain access to it. You may want to explore the following query:

Ultimately, we have the capability to combine the individual results to provide a broader overview by employing SubQuery aggregates. If you wish to determine the gas consumption for the most recent 100 transactions executed, grouped by signer addresses, you can employ the following query:

In summary, SubQuery’s SDK streamlines the procedure for developers to access AI data of the FetchAI protocol, showcasing its functionalities. This showcases how developers can effortlessly integrate on-chain data. Whether you’re building tools for analysing the Lens graph or creating decentralised applications for Web3 social data, SubQuery’s SDK stands out as the optimal solution for the job.

About Fetch-ai Network

Fetch-ai Network is delivering AI to the crypto economy. Autonomous Economic Agents, powered by artificial intelligence, provide automation to decentralised finance that can serve the needs of a single user or aggregate millions of data points for on-chain oracles. These agent-based systems provide greater flexibility, speed and crypto-economic security than existing layer-1 solutions and represent the future of decentralised finance. The Fetch-ai network is an interchain protocol, based on the Cosmos-SDK, and uses a high-performance WASM-based smart contract language (CosmWasm). This also allows the Fetch-ai network to serve as a layer-1 network for Ethereum and as an interchain bridge to the rest of the blockchain world.

Twitter | Linkedin | Website | Discord | Reddit | Telegram | Linktree | Youtube

About SubQuery

SubQuery is a leading blockchain data indexer that provides developers with fast, flexible, universal, and decentralised APIs for web3 projects. We empower developers from almost 120 ecosystems including Ethereum, Polygon, Polkadot, Cosmos, Algorand, NEAR, and Avalanche with rich indexed data to allow them to build intuitive and immersive decentralised applications. This blockchain developer toolkit enables developers to focus on their core use case and front-end without wasting time building a custom backend for data processing activities. In the near future, the SubQuery Network will replicate this scalable and reliable solution in a completely decentralised manner.

Linktree | Website | Discord | Telegram | Twitter | Matrix | LinkedIn | YouTube

--

--

SubQuery Network

SubQuery is here to help you transform and query the world’s data for a web3.0 future. https://subquery.network/