Using the Indexer

Using the indexer

The source code of a MUD client has a call either to syncToRecs (opens in a new tab) or to syncToZustand (opens in a new tab), typically in setupNetwork.ts (opens in a new tab). This call initializes the synchronization between the data source (RPC or indexer) and the client's copy.

To use the indexer, specify an indexerUrl parameter with the URL.

const { components, latestBlock$, storedBlockLogs$, waitForTransaction } = await syncToRecs({
  world,
  config: mudConfig,
  address: networkConfig.worldAddress as Hex,
  publicClient,
  startBlock: BigInt(networkConfig.initialBlockNumber),
  indexerUrl: "https://indexer.mud.redstonechain.com/",
});

If the client does not need all the information stored in the World, you can filter the synchronization to save on resources.

What URL to use

If you use our blockchains, either production (Redstone) (opens in a new tab) or testing (Garnet) (opens in a new tab), we provide an indexer you can use.

  • Redstone: https://indexer.mud.redstonechain.com/
  • Garnet: https://indexer.mud.garnetchain.com/

Note that those indexers are still experimental, and there might be downtime. If you need production-level reliability, contact us on Discord (opens in a new tab).

If you use a different blockchain, you need to host your own indexer, using either SQLite or PostgreSQL.