Skip to content

tryghostxyz/ghost-cli

Repository files navigation

Ghost CLI

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

  1. Ensure that Rust and Cargo are installed on your system. If not, install them from https://rustup.rs/.

  2. Clone the Ghost CLI repository:

    git clone https://github.com/tryghostxyz/ghost-cli.git
    cd ghost-cli
  3. Build the project:

    cargo build --release
  4. The binary will be available at target/release/ghost.

  5. (Optional) Move the binary to your $PATH for 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
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)

Code Generation

After modifying schema.sol and events.sol, generate the necessary indexer and related files:

ghost codegen

Compile Graph

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 Graph

Deploy a successfully compiled graph to the Ghost server:

ghost deploy

List Graphs

To view a list of your active or draft graphs:

ghost list

Fork an Existing Graph

Fork an existing graph and create a new directory:

ghost fork --id <graph_id> <directory>

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.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages