How to Query our Contracts
Last updated
Last updated
All rights to the people (c) 2023 Symmetry Labs A.G.
SYMMIO's core contracts are implemented with EIP-2535, a solution for building modular and upgradeable contracts.
EIP-2535 introduces the Diamond Standard in smart contract development. This standard centralizes around the concept of a "Diamond" contract, which is constructed from multiple "facets," each responsible for different functionalities. This modular design enhances maintainability by allowing facets to be upgraded or modified independently without affecting the entire contract. Key to this architecture are function selectors, which serve as unique identifiers for each function within the facets. These selectors efficiently direct function calls to the correct facet, facilitating organized and conflict-free code execution. For further reading and technical details, refer to the official EIP-2535 documentation.
When a facet, is invoked via a delegatecall
from the Diamond, it operates directly on the Diamondâs storage. The facet uses the slot address computed by the library to access or modify the data in the specific storage slot. This operation is transparent to the Diamond itself.
In the SYMM Diamond, the facets()
function of the DiamondLoupeFacet
plays a crucial role in inspecting the contract's structure and behaviour. When this function is called on the Diamond, it returns an array of Facet
structs, each containing the address of a facet along with the specific function selectors associated with that facet.
To examine the facets and call functions on them, we'll use a tool called Louper. This platform displays all facets and functions related to a Diamond contract and allows us to query data directly from them. Since functions cannot be called on through the Diamond contract directly through a blockchain explorer, Louper provides an efficient and user-friendly way to interact with the Diamond.
In this example, we'll use Louper to find all the contract symbols available to trade on Thena.
First, paste the address into the tool and select the appropriate chain (BNB):
Then, click the Read tab, and select the View Facet. This shows all the view functions available to query on the Diamond.
Now you can query the symbols available to trade on the Diamond using getSymbols()
with start
and size
as parameters:
For more information on the View Facet's functions, please refer to the ViewFacet documentation (0.8.2).
The Graph is a decentralized protocol for indexing and querying blockchain data. You can also query data on the diamond using a subgraph URL provided by SYMM. In this example, we'll query the symbol data using the Apollo Client.
Prerequisites
Basic understanding of GraphQL
A tool for making HTTP requests, such as Postman, cURL, or a GraphQL client like Apollo Client
Endpoint URL
First identify a suitable endpoint:
This endpoint is the analytics endpoint for the SYMMIO Diamond on BNB.
Example Query
To fetch data, send a POST request to the endpoint with the GraphQL query:
Using cURL
https://api.studio.thegraph.com/query/62454/main_arbitrum_8_2/version/latest
https://api.studio.thegraph.com/query/62454/analytics_arbitrum_8_2/version/latest
https://api.studio.thegraph.com/query/62454/parties_arbitrum_8_2/version/latest
https://api.studio.thegraph.com/query/62454/fundingrate_arbitrum_8_2/version/latest
https://api.studio.thegraph.com/query/62454/events_arbitrum_8_2/version/latest
https://subgraph-api.mantle.xyz/subgraphs/name/main_mantle_8_2
https://subgraph-api.mantle.xyz/subgraphs/name/analytics_mantle_8_2/graphql
https://subgraph-api.mantle.xyz/subgraphs/name/parties_mantle_8_2/graphql
https://subgraph-api.mantle.xyz/subgraphs/name/parties_mantle_8_2/graphql
https://api.studio.thegraph.com/query/62454/main_blast_8_2/version/latest
https://api.studio.thegraph.com/query/62454/analytics_blast_8_2/version/latest
https://api.studio.thegraph.com/query/62454/parties_blast_8_2/version/latest
https://api.studio.thegraph.com/query/62454/fundingrate_blast_8_2/version/latest
https://api.studio.thegraph.com/query/62454/events_blast_8_2/version/latest
https://api.studio.thegraph.com/query/62454/main_bnb_8_2/version/latest
https://api.studio.thegraph.com/query/62454/analytics_bnb_8_2/version/latest
https://api.studio.thegraph.com/query/62454/parties_bnb_8_2/version/latest
https://api.studio.thegraph.com/query/62454/fundingrate_bnb_8_2/version/latest
https://api.studio.thegraph.com/query/62454/events_bnb_8_2/version/latest
https://api.studio.thegraph.com/query/62454/main_base_8_2/version/latest
https://api.studio.thegraph.com/query/62454/analytics_base_8_2/version/latest
https://api.studio.thegraph.com/query/62454/parties_base_8_2/version/latest
https://api.studio.thegraph.com/query/62454/fundingrate_base_8_2/version/latest
https://api.studio.thegraph.com/query/62454/events_base_8_2/version/latest