Skip to content

Commit

Permalink
Merge pull request #373 from hirosystems/fix-note
Browse files Browse the repository at this point in the history
Fixed note and tip formats
  • Loading branch information
LakshmiLavanyaKasturi authored Aug 8, 2023
2 parents 86cee6c + cc85bac commit 0fbfc76
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Bitcoind installation will download binaries in a zip format, `bitcoin-22.0-osx6
- Set a username of your choice for bitcoind and use it in the `rpcuser` configuration below.
- Set a password of your choice for bitcoind and use it in the `rpcpassword` configuration below.

>[!NOTE]
> **_NOTE:_**
>
> Make a note of the `rpcuser`, `rpcpassword` and `rpcport` values to use them later in the chainhook configuration.
```conf
Expand Down Expand Up @@ -48,7 +49,8 @@ zmqpubhashblock=tcp://0.0.0.0:18543
Now that you have `bitcoin.conf` file ready with the bitcoind configurations, you can run the bitcoind node.
In the command below, use the path to your `bitcoin.conf` file from your machine and run the command in the terminal.

> [!NOTE]
> **_NOTE:_**
>
> The below command is a startup process that might take a few hours to run.
```console
Expand Down Expand Up @@ -168,7 +170,8 @@ A JSON file `ordinals.json` is generated.
}
```

> [!NOTE]
> **_NOTE:_**
>
> You can get blockchain height and current block by referring to https://explorer.hiro.so/blocks?chain=mainnet
Now, use the following command to scan the blocks based on the predicates defined in the `ordinals.json` file.
Expand All @@ -179,7 +182,8 @@ chainhook predicates scan ordinals.json --config-path=./Chainhook.toml

The output of the above command will be a text file `inscription_feed.txt` generated based on the predicate definition.

> [!TIP]
> **_TIP:_**
>
> To optimize your experience with scanning, the following are a few knobs you can play with:
> - Use of adequate values for `start_block` and `end_block` in predicates will drastically improve the performance.
> - Reducing the number of network hops between the Chainhook and the bitcoind processes can also help, so your network setup can play a major role in performance.
Expand Down Expand Up @@ -219,7 +223,8 @@ A JSON file `ordinals_protocol.json` is generated. You can now edit the JSON bas
}
```

> [!Note]
> **_NOTE:_**
>
> The `start_block` is the required field to use the `http_post` `then-that` predicate.
Now, use the following command to scan the blocks based on the predicates defined in the `ordinals_protocol.json` file.
Expand Down Expand Up @@ -313,7 +318,8 @@ Understand the output of the above JSON file with the following details.

- The `rollback` payload includes the block header and the transactions that triggered the predicate for a past block that is no longer part of the canonical chain and must be reverted.

> [!TIP]
> **_TIP:_**
>
> You can also run chainhook service by passing multiple predicates.
> Example: ```chainhook service start --predicate-path=predicate_1.json --predicate-path=predicate_2.json --config-path=Chainhook.toml```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ events_keys = ["*"]

```

> [!NOTE]
> **_NOTE:_**
>
> Ensure that the `username`, `password`, and `rpc_port` values in the `Stacks.toml` file match the values in the `bitcoin.conf` file. Also, note the `rpc_bind` port to use in the `Chainhook.toml` configuration in the next section of this article.
### Configure Chainhook
Expand Down Expand Up @@ -98,7 +99,8 @@ Ensure the following configurations are matched to allow chainhook to communicat
| | rpc_bind | stacks_node_rpc_url |
| | endpoint | stacks_events_ingestion_port |

> [!NOTE]
> **_NOTE:_**
>
> The `bitcoind_zmq_url` is optional when running chainhook as a service using stacks because stacks will pull the blocks from Stacks and the Bitcoin chain.
## Scan blockchain based on predicates
Expand Down Expand Up @@ -161,7 +163,8 @@ A JSON file `print_event_1.json` is generated.
}
```

> [!NOTE]
> **_NOTE:_**
>
> You can get blockchain height and current block in the [Explorer](https://explorer.hiro.so/blocks?chain=mainnet).
The sample `arkadiko.txt` should look like this:
Expand All @@ -178,7 +181,7 @@ chainhook predicates scan print_event_1.json --testnet

The output of the above command will be a text file `arkadiko.txt` generated based on the predicate definition.

> [!TIP]
> **_TIP:_**
> To optimize your experience with scanning, the following are a few knobs you can play with:
> Use of adequate values for `start_block` and `end_block` in predicates will drastically improve the performance.
> Networking: reducing the number of network hops between the chainhook and the bitcoind processes can also help.
Expand Down Expand Up @@ -225,7 +228,8 @@ A JSON file `print_event_2.json` is generated.
}
```

> [!Note]
> **_NOTE:_**
>
> The `start_block` is the required field to use the `http_post` `then-that` predicate.
Now, use the following command to scan the blocks based on the predicates defined in the `print_event_2.json` file.
Expand Down Expand Up @@ -259,6 +263,7 @@ In this section, you'll learn how to initiate the chainhook service using the fo
- Now, the predicate registration server is running at `localhost:20456`. To dynamically register a new predicate, send a POST request to `localhost:20456/v1/chainhooks` with the new predicate, in JSON format, included in the request body. For complete documentation on the API endpoints available, see the [OpenAPI](https://raw.githubusercontent.com/hirosystems/chainhook/develop/docs/chainhook-openapi.json) specification.
- ![Example post request](../images/chainhook-post-request.jpeg)

> [!TIP]
> **_TIP:_**
>
> You can also run chainhook service by passing multiple predicates.
> Example: ```chainhook service start --predicate-path=predicate_1.json --predicate-path=predicate_2.json --config-path=Chainhook.toml```
3 changes: 2 additions & 1 deletion docs/how-to-guides/how-to-use-chainhooks-with-bitcoin.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ The following additional configurations can be used to improve the performance o

Retrieve and HTTP Post to `http://localhost:3000/api/v1/wrapBtc` the five first transfers to the p2wpkh `bcrt1qnxk...yt6ed99jg` address of any amount, occurring after block height 10200.

> [!NOTE]
> **_NOTE:_**
>
> The start_block is mandatory to post events using `http_post` `then-that` predicate.
```json
Expand Down

0 comments on commit 0fbfc76

Please sign in to comment.