CLI reference

Complete reference for all Chainhook CLI commands and options.

The Chainhook CLI provides tools for creating, testing, and deploying blockchain event observers. From predicate creation to service management, Chainhook streamlines your blockchain monitoring workflow.

Configuration management

chainhook config

chainhook config generates configuration files.

CommandDescription
newGenerate new config

Usage with new

chainhook config new [OPTIONS]
Terminal
$
chainhook config new --mainnet
OptionDescription
--mainnetTarget Mainnet network
--testnetTarget Testnet network
--devnetTarget Devnet network

Predicate management

chainhook predicates

chainhook predicates generates and tests predicates.

CommandDescription
newGenerate new predicate
checkCheck given predicate
scanScan blocks (one-off) from specified network and apply provided predicate

Usage with new

chainhook predicates new [OPTIONS] <NAME>
Terminal
$
chainhook predicates new my-predicate --stacks
$
chainhook predicates new bitcoin-transfers --bitcoin
OptionDescription
--stacksGenerate a Stacks predicate
--bitcoinGenerate a Bitcoin predicate

Usage with scan

chainhook predicates scan [OPTIONS] <PREDICATE_PATH>
Terminal
$
chainhook predicates scan my-predicate.json --mainnet
$
chainhook predicates scan transfers.json --testnet --config-path ./Chainhook.toml
OptionDescription
--mainnetTarget Mainnet network
--testnetTarget Testnet network
--config-path <path>Load config file path

Usage with check

chainhook predicates check [OPTIONS] <PREDICATE_PATH>
Terminal
$
chainhook predicates check my-predicate.json --mainnet
OptionDescription
--config-path <path>Load config file path
--mainnetTarget Mainnet network
--testnetTarget Testnet network

Service management

chainhook service

chainhook service runs a service streaming blocks and evaluating registered predicates.

CommandDescription
startStart chainhook-cli

Usage with start

chainhook service start [OPTIONS]
Terminal
$
chainhook service start --config-path=./Chainhook.toml
$
chainhook service start --predicate-path=./my-predicate.json --mainnet
OptionDescription
--config-path <path>Load config file path
--predicate-path <path>Specify relative path of the chainhooks (yaml format) to evaluate
--start-http-apiStart REST API for managing predicates
--prometheus-port <port>If provided, serves Prometheus metrics at localhost:{port}/metrics
--mainnetTarget Mainnet network
--testnetTarget Testnet network
--devnetTarget Devnet network

Stacks integration

chainhook stacks

chainhook stacks provides Stacks-specific commands.

CommandDescription
dbDb maintenance related commands

Usage with db

chainhook stacks db <SUBCOMMAND>
Terminal
$
chainhook stacks db check
$
chainhook stacks db update --config-path ./Chainhook.toml
SubcommandDescription
checkCheck integrity
dropUpdate blocks from database
getRetrieve a block from the Stacks db
get-latestGet latest blocks from the unconfirmed and confirmed block db
unconfirmDeletes a block from the confirmed block db and moves it to the unconfirmed block db
updateUpdate database using latest Stacks archive file
OptionDescription
--config-path <path>Load config file path

Utilities

chainhook docs

chainhook docs generates documentation.

CommandDescription
apiGenerate new documentation for the predicate registration API

Usage with api

chainhook docs api
Terminal
$
chainhook docs api

chainhook help

chainhook help prints help information.

Usage

chainhook help [SUBCOMMAND]
Terminal
$
chainhook help
$
chainhook help predicates

Global options

These options can be used with the main command:

OptionShortDescription
--help-hPrint help information
--version-VPrint version information