Predicate design
Predicates are the building blocks of Chainhook.
The core design of Chainhook revolves around the concept of predicates. Each individual Chainhook has a customizable predicate that specifies what the Bitcoin or Stacks blockchain data you are scanning for.
Commands outlined here will require that you have installed Chainhook directly.
Predicate design
Below is the general strucure of the predicate
JSON with its primary elements. These elements and their values are required.
- Chainhook will evaluate the predicate against the specfied blockchain specified in
chain
. - The
uuid
will be returned in the Chainhook payload, providing a record of the predicate that triggers it. - Identify your predicate for your DApp using
name
andversion
.
You can use the following command to verify your predicate:
Networks
The networks
element contains an object who's key determines the blockchain network you want Chainhook to scan.
- This object's value will contain the
if_this
and thenthen_that
specifications. - Multple networks can be specified in the
networks
element.
For additional information, check out the Bitcoin scopes and Stacks scopes references pages.
if_this specification
The predicate
identifies what data you want Chainhook to scan for using the scope
define within the if_this
specification. Additional arguments specific to the scope
will also be passed here.
then_that specification
Chainhook delivers the payload when it is triggered by your predicate
using the then_that
specification. There are 2 options available:
file_append
http_post
When choosing to use file_append, specify the path where Chainhook will post the payload data.
When using http_post
, specify the endpoint's url
and authorization_header
.
Chainhook requires https
to post to your endpoint. You can use a service like LocalTunnel to test locally or a site like WebhookSite.
Blockchain specific configurations
The following command allows you to generate a predicate template for the Bitcoin blockchain.
Next steps
Observing contract calls
Learn use a predicate to observe Stacks contracts calls with Chainhook.
Create a Chainhook
Learn how to create a Chainhook using the Hiro Platform.
Stacks scopes
Learn how to use additional scopes to scan for specific Stacks blockchain events.
Bitcoin scopes
Learn how to use additional scopes to scan for specific Bitcoin blockchain events.