API
The API can be used to serve data to users about the protocol. Due to the blockchain nature, data must first be confirmed and indexed by the API back-end before being available. This can generally take between 100ms - 60 seconds, depending on the time to confirm and process a block. The API works by indexing data from the Infinity Protocol contracts. It organizes or uses that data to create new data about users, liquidity pairs, tokens, overall platform stats and much more, which is then served via the GraphQL API.
Every time there is a new transaction made on the Infinity Protocol the API will update, this can be a trade, add liquidity or remove liquidity

API Workflow

Data is indexed and saved according to the following process:
1- A decentralized application interacts with the Blockchain through a transaction on a smart contract.
2- The smart contract emits one or more events while processing the transaction.
3- Graph Node continually scans the blockchain for new blocks and any data in the new blocks related to the smart contract interaction.
4- Graph Node finds blockchain events for your subgraph in these blocks and runs the mapping handlers you provided. The mapping is a WASM module that creates or updates the data entities that Graph Node stores in response to blockchain events.
5- The decentralized application queries the Graph Node for data indexed from the blockchain, using the node's GraphQL endpoint. The Graph Node in turn translates the GraphQL queries into queries for its underlying data store to fetch this data, making use of the store's indexing capabilities.
6- The decentralized application displays this data in a rich UI for end-users, which they can use to understand their history and monitor their wallet with graphs and other information.
7- The cycle repeats on every new transaction.
The API is only used to query data, it is not used to interact with the smart contracts. All interactions with the smart contracts are made directly by the user to the blockchain with their wallet, for maximum decentralization and security.
Last modified 6mo ago
Export as PDF
Copy link
Contents
API Workflow