ghost-cli is a command-line tool for interacting with the Ghost server.
You can now fork and edit graphs locally which means you can use any editor (and AI tool!) to work on your indexers.
Installation
-
Ensure that Rust and Cargo are installed on your system. If not, install them from https://rustup.rs/.
-
Clone the Ghost CLI repository:
git clone https://github.com/tryghostxyz/ghost-cli.git cd ghost-cli -
Build the project:
-
The binary will be available at
target/release/ghost. -
(Optional) Move the binary to your
$PATHfor easy access:mv ./target/release/ghost /usr/local/bin/
Usage
Configure Ghost API (Required)
Set up your Ghost API key by running the following command:
ghost configure <API_KEY>
To generate an API key, visit Ghost Graphs and click the "API Key" button. You must use an admin API key to configure.
Create a Ghost Graph
Create your first Ghost graph by specifying the chain and directory:
ghost create --chain <chainId or slug> <directory>
Available chains:
- eth-mainnet
- eth-sepolia
- base-mainnet
- base-sepolia
- bera-testnet
- blast-mainnet
- abstract-testnet
- uni-testnet
ghost events --api_key <ETHERSCAN_API_KEY> --address <CONTRACT_ADDRESS>
This will return the events from a verified contract that you can be used in your events.sol file.
Example:
ghost create --chain bera-testnet honeypot-finance
This will generate a new directory with the following files:
schema.solevents.solconfig.json(which includes the graph ID and version ID for future commands)
Code Generation
After modifying schema.sol and events.sol, generate the necessary indexer and related files:
Compile Graph
Compile the graph by sending indexer.sol to the Ghost server for validation:
If any errors occur, they will be displayed. Ensure that the code passes compilation before deploying. If you make
changes to events.sol or schema.sol, re-run the codegen command.
Deploy Graph
Deploy a successfully compiled graph to the Ghost server:
List Graphs
To view a list of your active or draft graphs:
Fork an Existing Graph
Fork an existing graph and create a new directory:
ghost fork --id <graph_id> <directory>
Fork an Existing Graph And Delete The Old Graph
Fork an existing graph in the current Ghost directory and delete the old graph
ghost fork --replace --delete .Delete an Existing Graph
Delete an existing graph
ghost delete --id <graph_id>
Error Handling
If an error occurs during any operation, Ghost CLI will display a detailed error message. Verify that your API key, graph ID, and version ID are correctly configured, and ensure an active internet connection when interacting with the Ghost server.
For support, join our Ghost Telegram Group.
Questions?
For additional support, visit our Documentation or join our Telegram Group.
License
This project is licensed under both the Apache and MIT Licenses.