Learn how to stream data and post it to an external endpoint.
Ordhook is a tool that helps you find Ordinals activity on the Bitcoin chain and build your own customized database with that data. This guide will show you how to use Ordhook to stream Ordinals activity.
This section walks you through streaming Ordinals activity. To post that activity, you'll need to configure bitcoind. Refer to setting up a bitcoin node to understand the steps to configure Bitcoind.
Ordhook is applicable to the Bitcoin chain only.
Once the Bitcoin node is configured, you can use the following command in your terminal to create a configuration for Ordhook:
ordhook config new --mainnet
You will see a success message "Created file Ordhook.toml" in your terminal.
The generated Ordhook.toml file looks like this:
[storage]
working_dir="ordhook"
# The http API allows you to register / deregister predicates dynamically.
# This is disabled by default.
#
# [http_api]
# http_port = 20456
# database_uri = "redis://localhost:6379/"
[network]
mode="mainnet"
bitcoind_rpc_url="http://0.0.0.0:8332"
bitcoind_rpc_username="devnet"
bitcoind_rpc_password="devnet"
# Bitcoin block events can be received by Chainhook
# either through a Bitcoin node's ZeroMQ interface,
# or through the Stacks node. Zmq is being
# used by default:
bitcoind_zmq_url="tcp://0.0.0.0:18543"
# but stacks can also be used:
# stacks_node_rpc_url = "http://0.0.0.0:20443"
[limits]
max_number_of_bitcoin_predicates=100
max_number_of_concurrent_bitcoin_scans=100
max_number_of_processing_threads=16
bitcoin_concurrent_http_requests_max=16
max_caching_memory_size_mb=32000
# Disable the following section if the state must be built locally
Observe that the bitcoind configured fields will appear in the Ordhook.toml file. Now, ensure that these fields are configured with the right values and URLs, as shown below:
After adjusting the Ordhook.toml settings to make them match the bitcoind configuration, the following command can be run to scan blocks and post events to a local server:
The above command uses Ordhook to stream and then post Ordinals activity to http://localhost:3000/api/events where you can build out your own database or custom views.