First, within your Clarinet project, you'll need to create your Chainhook predicate files.
These should be situated in the root of your project directory. The files can either be separate or stored within a specific folder, e.g., /chainhooks in your project root directory:
counter.clar
increment.json
decrement.json
counter.test.ts
.gitignore
Clarinet.toml
package.json
tsconfig.json
vitest.config.js
For examples on how to define your predicates, refer to the scopes reference page.
To start devnet, run the clarinet devnet start command from the root of your project directory. Running this command will begin a local Chainhook service in the background that automatically registers your Chainhook files within the project directory against the network.
Once your devnet starts, the Chainhook service initiates the registration process. You'll know that the registration of your Chainhooks was successful by checking the confirmation message in your terminal:
Terminal
$
clarinet devnet start
If you do not see this message at the top of your clarinet devnet start logs, verify that you are using clarinet version 2.1.0 or higher.
With these steps completed, your chainhooks are ready to trigger whenever local contract actions occur. You can monitor your network activity locally, through the _clarinet devnet start terminal, to confirm chainhooks execution as you further develop and test your smart contracts. When an action occurs, you should see something like this:
Terminal
$
clarinet devnet start
At this point, you can verify the payload for that action depending on whether you are expecting an http_post or file_append result from your then_that configuration.