Ghost

The new Smart Contract Indexing Stack

With GhostGraph, you can write your indexers in the same language as your contracts: Solidity. This means less context switching and faster time to market.

Smart Contract Indexing Stack Diagram

Trusted by

Metastreet
Amberdata
Magnify Cash
Plutocats
Honeypot
Dyli
Tokiemon
Metastreet
Amberdata
Magnify Cash
Plutocats
Honeypot
Dyli
Tokiemon

Introducing the blazingly fast way to spin up an indexer for your smart contracts. All in Solidity

Define your Schema

Create your schema by defining entities. In GhostGraph, you write your entities using Solidity structs

schema.sol•
solidity
struct Pair {
    address id;
    address token0;
    address token1;
    uint256 reserve0;
    uint256 reserve1;
    @many(Swap.pairId) swaps;
    uint32 createdAt;
}

struct Swap {
    string id;
    @belongsTo(Pair.id) pairId;
    uint256 amount0In;
    uint256 amount1In;
    uint256 amount0Out;
    uint256 amount1Out;
}

Write your handlers

After you've defined your schema and events, GhostGraph will generate a base indexer.sol file for you. Here you can register contracts and fill in the callback functions with your indexer logic. All in Solidity

indexer.sol•
solidity
contract MyIndex is GhostGraph {
    using StringHelpers for EventDetails;
    
    function registerHandles() external {
        graph.registerFactory(0xb4A7D971D0ADea1c73198C97d7ab3f9CE4aaFA13, GhostEventName.PairCreated, "pair");
        graph.registerHandle(0xb4A7D971D0ADea1c73198C97d7ab3f9CE4aaFA13);
    }

    function onSwap(EventDetails memory details, SwapEvent memory ev) external {
        Swap memory swap = graph.getSwap(details.uniqueId());
        swap.amount0In = ev.amount0In;
        swap.amount0Out = ev.amount0Out;
        swap.amount1In = ev.amount1In;
        swap.amount1Out = ev.amount1Out;
        swap.pairId = details.emitter;
        graph.saveSwap(swap);
    }
}

Query via GraphQL

Deploy your graph to the hosted GhostGraph service. Once the indexing engine has synced to the tip of the chain, you can query your index using GraphQL. There's also a playground for you to test your queries

query.graphql•
GraphQL
query GetAllSwaps {
  swaps {
    items {
      id
      txHash
      pairId
      amount0In
      amount0Out
      amount1In
      amount1Out
    }
  }
}

Supported Chains

AbstractChain
Base
Berachain
Blast
Ethereum
Unichain

What People Are Saying

Trusted by developers and teams worldwide

"This advanced tool can make your life a lot easier by handling the event based data which your dapp needs from the chain. You can move all the onchain data fetching logic from your dapp into their graph and access it very easily. Highly recommending to check it out."

Arcanum
Arcanum
Co-Founder
Company logo

"Indexing is always a pain point for web3 projects, but GhostGraph makes the job a lot easier. Easy-to-customize data fetching logic, along with great performance from their backend, makes this a tool worth trying out for your next project"

Rizzo
Rizzo
CTO
Company logo

"One of the standout features of GhostGraph is the ability to share, fork, and modify other GhostGraphs. This functionality fosters a collaborative environment and greatly enhances the developer experience. By leveraging shared graphs, I can quickly gain insights from others' work, adapt their solutions to my specific needs, and significantly reduce the time it takes to go from a question to an actionable insight."

Pat Doyle
Pat Doyle
Head of Blockchain Research
Company logo

"Ghost has been a game-changer for us at DYLI, helping us index and query blockchain data in real-time across all our contracts. The initial setup was super quick and straightforward, and it’s made our marketplace run seamlessly."

Alex Needelman
Alex Needelman
Co-Founder
Company logo

Frequently asked questions

You can reach out to us in our community Telegram

Check out our documentation for use cases and examples


Write your first GhostGraph in Solidity Today

Join developers worldwide building the future of blockchain data indexing