Skip to main content

Graphcast CLI

The source code for the Graphcast CLI is available on GitHub.

Introduction

The Graphcast CLI enables sending one-off messages. Currently, it can be used for the Subgraph Upgrade Pre-sync feature of Subgraph Radio.

The Graphcast CLI is configured using config variables. You will need to prepare the following config variables (either as env variables or passing CLI args when running the CLI):

NameDescription and Examples
PRIVATE_KEYPrivate key to the Graphcast ID wallet (precendence over mnemonics).
Example: PRIVATE_KEY=YOUR_PRIVATE_KEY
MNEMONICMnemonic to the Graphcast ID wallet (first address of the wallet is used; Only one of private key or mnemonic is needed).
Example: MNEMONIC=YOUR_MNEMONIC
GRAPH_ACCOUNTGraph account corresponding to Graphcast operator.
Example: GRAPH_ACCOUNT=YOUR_GRAPH_ACCOUNT
REGISTRY_SUBGRAPHSubgraph endpoint to the Graphcast Registry.
Default: https://api.thegraph.com/subgraphs/name/hopeyen/graphcast-registry-goerli
NETWORK_SUBGRAPHSubgraph endpoint to The Graph network subgraph.
Default: https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-goerli
GRAPHCAST_NETWORKSupported Graphcast networks: mainnet, testnet.
Default: testnet
LOG_LEVELLogging configuration to set as RUST_LOG.
Default: info
LOG_FORMATSupport logging formats: pretty, json, full, compact.
Default: pretty

The Graphcast CLI code is very extensible and could be altered to send any kind of Graphcast-compatible message to the network.

Usage

The Graphcast CLI supports the following subcommands - upgrade-presync and indexing-status. Both of them work with additional configuration options:

NameDescription and Examples
SUBGRAPH_IDSubgraph id shared by the old and new deployment.
NEW_HASHSubgraph hash for the upgrade version of the subgraph.

The upgrade-presync subcommand has an additional MAX_RETRY variable, which specifies the number of retries for the subcommand. The default value is 5.

Below you can see examples of working CLI commands.

Run with Docker

  1. Pull the Graphcast CLI image
docker pull ghcr.io/graphops/graphcast-cli:latest
  1. Run the image, providing the required configuration variables. Here's a sample configuration:
docker run ghcr.io/graphops/graphcast-cli \
--private-key "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
--graph-account "0xe9a1cabd57700b17945fd81feefba82340d9568f" \
upgrade-presync --new-hash "QmVVfLWowm1xkqc41vcygKNwFUvpsDSMbHdHghxmDVmH9x" \
--subgraph-id "CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3"

(or) Run using a pre-built binary

We also provide pre-built binaries for Ubuntu and MacOS, which you can find in the Assets section on each release in the releases page on Github. Simply download the binary, make it executable (chmod a+x ./graphcast-cli-{TAG}-{SYSTEM}) and then run it (using ./graphcast-cli-{TAG}-{SYSTEM}), like this:

./graphcast-cli-0.0.1-macos \
--private-key "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
--graph-account "0xe9a1cabd57700b17945fd81feefba82340d9568f" \
upgrade-presync --new-hash "QmVVfLWowm1xkqc41vcygKNwFUvpsDSMbHdHghxmDVmH9x" \
--subgraph-id "CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3"

(or) Run using a pre-built binary

  1. Clone the repo
git clone https://github.com/graphops/graphcast-cli.git
  1. Navigate to the project directory
cd graphcast-cli
  1. Run the CLI
cargo run --release -- --private-key "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
--graph-account "0xe9a1cabd57700b17945fd81feefba82340d9568f" \
upgrade-presync --new-hash "QmVVfLWowm1xkqc41vcygKNwFUvpsDSMbHdHghxmDVmH9x" \
--subgraph-id "CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3"