You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/stacks/chainhook/concepts/predicate-design.mdx
+316-31
Original file line number
Diff line number
Diff line change
@@ -3,62 +3,347 @@ title: Predicate design
3
3
description: Predicates are the building blocks of Chainhook.
4
4
---
5
5
6
-
The core design of chainhooks revolves around the concept of predicates. Each individual chainhook has a customizable predicate that specifies what information you are scanning for.
6
+
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.
7
7
8
-
Predicates are defined in an `if-this`, `then-that` format. You'll write your condition in the `if-this` condition template and use `then-that` to output the result.
8
+
<Callouttype="warn"title="Requirements">
9
+
Commands outlined here will require that you have installed Chainhook [directly](/stacks/chainhook/installation).
10
+
</Callout>
9
11
10
-
## `if-this`
12
+
## Predicate design
13
+
Below is the general strucure of the `predicate` JSON with its primary elements. These elements and their values are required.
11
14
12
-
The `if-this` predicate design can use the following attributes to define the predicates. The 'scope' parameter is mandatory to use with any other parameters.
15
+
- Chainhook will evaluate the predicate against the specfied blockchain specified in `chain`.
16
+
- The `uuid` will be returned in the Chainhook payload, providing a record of the predicate that triggers it.
17
+
- Identify your predicate for your DApp using `name` and `version`.
The `networks` element contains an object who's key determines the blockchain network you want Chainhook to scan.
41
+
- This object's value will contain the `if_this` and then `then_that` specifications.
42
+
- Multple networks can be specified in the `networks` element.
43
+
44
+
```json
45
+
"networks": {
46
+
"mainnet": {
47
+
// if_this and then_that specifications
48
+
// Other configurations
49
+
},
50
+
"testnet": {
51
+
// if_this and then_that specifications
52
+
// Other configurations
53
+
},
54
+
}
55
+
```
33
56
34
-
<Callouttitle="Info">
35
-
For more information on predicate definitions, refer to the [scopes](/stacks/chainhook/references/scopes) reference page.
57
+
<Callouttype="info"title="Note">
58
+
For additional information, check out the [Bitcoin scopes](/stacks/chainhook/references/scopes/bitcoin) and [Stacks scopes](/stacks/chainhook/references/scopes/stacks) references pages.
36
59
</Callout>
37
60
38
-
## `then-that`
61
+
## if_this specification
62
+
63
+
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.
Chainhook requires `https` to post to your endpoint. You can use a service like [LocalTunnel](https://github.com/localtunnel/localtunnel) to test locally or a site like [WebhookSite](https://webhook.site).
0 commit comments