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.

dapp

Trusted by

Trusted by: 1Trusted by: 2Trusted by: 3Trusted by: 4Trusted by: 5Trusted by: 6Trusted by: 7Trusted by: 8Trusted by: 9Trusted by: 10Trusted by: 11Trusted by: 12Trusted by: 13Trusted by: 14Trusted by: 15Trusted by: 16

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

Solidity

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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; }

Define your Schema

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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); } function onSync(EventDetails memory details, SyncEvent memory ev) external { Pair memory pair = graph.getPair(ev.pair); pair.reserve0 = ev.reserve0; pair.reserve1 = ev.reserve1; graph.savePair(pair); } function onPairCreated(EventDetails memory details, PairCreatedEvent memory ev) external { Pair memory pair = graph.getPair(ev.pair); pair.token0 = ev.token0; pair.token1 = ev.token1; pair.createdAt = details.timestamp; graph.savePair(pair); } }

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 factory addresses) and fill in the callback functions with your indexer logic. All in Solidity

1 2 3 4 5 6 7 8 9 10 11 12 13 query GetAllSwaps { swaps { items { id txHash pairId amount0In amount0Out amount1In amount1Out } } }

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


Supported Chains

AbstractChainBaseBerachainBlastEthereumUnichain

Testimonials

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
Profile picture

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
Profile picture

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
Profile picture

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
Profile picture

Frequently asked questions

You can reach out to us in our community Telegram

Check out our documentation for use cases and examples


Featured Blog Articles


Write your first GhostGraph in Solidity Today


Privacy Policy

 • 

Terms of Service

Copyright © Ghost. All rights reserved.