> ## Documentation Index
> Fetch the complete documentation index at: https://docs.soroswap.finance/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Soroswap Aggregator API: base URL https://api.soroswap.finance, pick the network with ?network=mainnet or ?network=testnet (omitted means mainnet).
> Auth: Authorization: Bearer sk_... on every call. Get a key at https://console.soroswap.finance/register. A missing or invalid key returns 401 with code and registerUrl (POST /send returns 403 instead); an expired JWT or a missing role returns 403. Free plan 1 request/s; see https://docs.soroswap.finance/api/plans.md.
> Flow: POST /quote (assetIn, assetOut as C... contract addresses, amount as an integer string in the smallest unit, tradeType, protocols) -> POST /quote/build with the unchanged quote and from -> the user signs the XDR -> POST /send. Build right after quoting: a Soroban XDR is valid for 180 seconds. Submit it as is, never re-simulate it.
> Partner id: every account has one (9 hex chars, permanent). Read partnerId from GET /partner, or in the console at https://console.soroswap.finance under Fees & payouts. The partner fee itself is switched on by Soroswap; see https://docs.soroswap.finance/api/fees.md.
> AI tools: docs MCP at https://docs.soroswap.finance/mcp (claude mcp add --transport http soroswap-docs https://docs.soroswap.finance/mcp), skill with npx skills add https://docs.soroswap.finance. Other clients: https://docs.soroswap.finance/api/build-with-ai.md.
> Units and Stellar pitfalls: https://docs.soroswap.finance/api/stellar-gotchas.md. Errors and retries: https://docs.soroswap.finance/api/errors.md.

# Collaboration with Mercury and SubQuery

> Soroswap's work with the Mercury and SubQuery indexers, with setup steps for both.

This article outlines the outcomes and walkthroughs of our collaborative projects with Mercury and SubQuery indexers. We aim to achieve two primary objectives:

1. Introduce developers from the Stellar and Soroban ecosystems to the capabilities of indexer services.
2. Assist indexers in refining their offerings by reporting bugs and providing documentation feedback we've uncovered through our usage.

## The Importance of Indexers in Blockchain Ecosystems

Utilizing indexers is crucial for efficient data retrieval, thereby enabling developers to offer a seamless user experience. Although blockchains inherently ensure transactional integrity, extracting an entire history directly from a node is computationally intensive. Therefore, indexers serve as invaluable tools. This article serves two main goals:

* Demonstrate practical uses of the indexer as an example or initial repository.
* Test various indexer solutions, offering constructive feedback on bugs and documentation.

## Mercury: Subscription-Based Indexing Solutions

Mercury offers a subscription-based indexing service equipped with numerous features such as alert systems and code execution environments. As a fully managed service, Mercury obviates the need for developers to manage any GraphQL service themselves.

In our repository, you'll find a Node.js client pre-configured with queries to inspect a specific contract, specified through the repository's environment variables.

### Getting Started with Mercury

**Prerequisites**: Docker installation on your machine

1. Clone the repository: `https://github.com/paltalabs/mercury-client.git`
2. Duplicate `.env.example` as `.env`
3. Request Mercury access [here](https://developers.mercurydata.app/requesting-access)
4. Populate the `MERCURY_ACCESS_TOKEN` in `.env`. For usage exceeding 7 days, also complete `MERCURY_TESTER_EMAIL` and `MERCURY_TESTER_PASSWORD`.
5. Update `CONTRACT_ADDRESS` if you are interested in a contract other than the Soroswap's Factory contract.
6. Run the container: `bash run.sh`
7. Install dependencies: `yarn`
8. Use predefined scripts to interact with the contract:

   ```
   node scripts/subscribeToEntries.js
   node scripts/getAllEntriesForContract.js
   node scripts/getEntrySubscriptions.js
   node scripts/getEventSubscriptions.js
   ```

## SubQuery: Versatile Indexing for Multiple Platforms

SubQuery is a comprehensive indexer that interfaces seamlessly with multiple blockchain platforms, including Stellar and Soroban. We've developed a customized SubQuery project capable of IPFS deployment and management through SubQuery's Managed Service.

However, storing blockchain history requires access to an archive node, which adds an operational dependency: you either run one yourself or rely on a provider that does. This is the main trade-off to weigh against a fully managed indexing service.

### Getting Started with SubQuery

**Requirements**: Docker

Our setup incorporates Docker inside a Node.js image to manage the required Node.js version and to prevent the need for a global `subql` package installation. If you prefer to install node, docker and subql locally you can start from step 4.

1. Run the container: `bash run.sh`
2. Install Docker and SubQuery:

   ```
   bash install_docker.sh
   bash setup_subquery.sh
   ```
3. Navigate to `subql-starter` directory and execute:

   ```
   yarn
   dockerd &
   ```
4. In another terminal

   ```
   bash connect.sh
   ```

   and (if you prefer to install node, docker and subql locally you can start from here)

   ```
   cd subql-starter
   yarn codegen
   yarn build
   yarn start:docker
   ```
5. Begin querying by navigating to `http://localhost:3000/graphql`
6. To publish your project to IPFS, run:

   ```
   cd subql-starter
   subql publish
   ```

### Conclusion

We've demonstrated how to leverage both Mercury and SubQuery indexers, reporting bugs and providing documentation feedback along the way. Each service offers unique approaches to solving data availability issues. While SubQuery provides a more mature and UI-rich solution, its requirement for an archive node adds complexity. Mercury, however, simplifies the process by only requiring subscriptions and queries, thereby eliminating the need to manage additional infrastructure.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.