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.
-
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:
cargo build --release
-
The binary will be available at
target/release/ghost
. -
(Optional) Move the binary to your
$PATH
for easy access:mv ./target/release/ghost /usr/local/bin/
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 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
ghost events --api_key <ETHERSCAN_API_KEY> --contract <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.sol
events.sol
config.json
(which includes the graph ID and version ID for future commands)
After modifying schema.sol
and events.sol
, generate the necessary indexer and related files:
ghost codegen
Compile the graph by sending indexer.sol
to the Ghost server for validation:
ghost compile
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 a successfully compiled graph to the Ghost server:
ghost deploy
To view a list of your active or draft graphs:
ghost list
Fork an existing graph and create a new directory:
ghost fork --id <graph_id> <directory>
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.
For additional support, visit our Documentation or join our Telegram Group.
This project is licensed under both the Apache and MIT Licenses.