⚠️ WARNING: This code is experimental and pre-release. Use at your own risk.
This repo contains the indexer for the Kontor Protocol, comprised of:
- Bitcoin follower: Reconciles streams of block data from Bitcoin's ZMQ socket and RPC API.
- Bitcoin block parser: Extracts Kontor
Instructions from Bitcoin transactions and converts them intoOperations. - Reactor (event loop): Synchronizes
Operations and handles them. - WASM Component Model-based Runtime: Deterministically runs
CallOperations on smart-contract WASM components. - HTTP API: Exposes indexer data, supports "view" (read-only contract call) functionality, and provides endpoints for the composition of Bitcoin transactions with embedded Kontor
Instructions. - WebSocket API: Emits contract call results enabling applications to build and maintain their own derived state by reacting to incremental updates and deliver a real-time experience to end-users.
indexer: Builds into thekontorbinary, the primary executable for the Kontor Protocol.stdlibandtestlib: Crates used when developing contracts.macros: Contains the procedural macros used in the Sigil smart contract framework.
Contains the contracts native to Kontor, providing the core functionality of the protocol.
Contains a variety of contracts used to test the indexer.
GET /healthz/live is process liveness. GET /healthz/ready returns 503 until
the reactor is initialized and indexed state is within one block of a recent,
non-IBD Bitcoin observation on the configured network. Observations expire after
30 seconds; successful existing getblockchaininfo calls refresh them across
client clones. Probes read local state and send no additional RPCs. The response
includes bitcoin_height and bitcoin_synced and is marked no-store.
Use readiness, not liveness, to withdraw traffic during startup/replay or shutdown. A failed readiness check must not restart a healthy replay. Public request draining and protocol/consensus behavior are unchanged. This compares local progress with the configured Bitcoin backend; it is not proof of external network freshness, checkpoint agreement or validator signing eligibility.
For deployment, both Kubernetes readiness and load-balancer HTTP health checks
must use /healthz/ready. Older pinned images do not implement this contract;
do not change their probe path before a compatible image and isolated recovery
rehearsal pass. This source change alone does not upgrade retained production.
GET /api/protocol supplies exact checkpoint and protocol context for comparing
nodes at a common completed position. GET /metrics supplies cached operational
progress, freshness, and managed consensus metrics. See Node observations and
metrics for comparison rules, metric semantics, and example
queries.
MacOS:
brew install cmake pkgconf libevent boost zmq brotliUbuntu:
sudo apt install cmake pkgconf libevent-dev libboost-all-dev libzmq3-dev brotliIf rust tooling is not installed follow steps from rust-lang.org
Host builds use Rust 1.100.0, pinned in CI and the linked-node builder. Install it with rustup toolchain install 1.100.0 --component rustfmt,clippy,llvm-tools-preview. For local Cargo commands, select it with RUSTUP_TOOLCHAIN=1.100.0 (including when using the shared local-build helper).
Reproducible contract and SDK component generation also uses Rust 1.100.0, through the published image pinned in tools/build.json. Keep the host and reproducible build compiler versions aligned when upgrading Rust, regenerate the outputs, and verify them with ./tools/kontor build --check. Host selection stays explicit so local toolchain overrides cannot silently replace the compiler pinned inside the build container.
Add wasm compile target:
rustup target add wasm32-unknown-unknownInstall cargo components
cargo install cargo-expand wasm-optA local copy of bitcoind is required to run all tests successfully.
Install dependencies for compiling Bitcoin:
Clone Bitcoin:
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
git checkout v30.0Compile Bitcoin:
cmake -B build -DENABLE_WALLET=OFF -DENABLE_IPC=OFF -DWITH_ZMQ=ON
cmake --build buildCompiled binaries including bitcoind are located in build/bin. This directory must be on your $PATH when running tests.
git clone https://github.com/KontorProtocol/Kontor.git
cd Kontor/core
cargo test --workspaceSome machines may not have the resources to compile all tests concurrently. In these cases, use the --jobs flag or the CARGO_BUILD_JOBS environment variable to limit the number of simultaneous compilation jobs.
Long running tests are ignored by default. To run them, use the --ignored or --include-ignored flags.
Build the Alpine-based image:
docker build -t kontor-indexer .Run with environment variables:
docker run -d \
-p 9333:9333 \
-v kontor-data:/data \
-e BITCOIN_RPC_URL=http://your-node:8332 \
-e BITCOIN_RPC_USER=your-username \
-e BITCOIN_RPC_PASSWORD=your-password \
-e ZMQ_ADDRESS=tcp://your-node:28332 \
-e NETWORK=bitcoin \
kontor-indexerOr pass CLI arguments directly:
docker run -d -p 9333:9333 -v kontor-data:/data kontor-indexer \
--bitcoin-rpc-url http://your-node:8332 \
--bitcoin-rpc-user your-username \
--bitcoin-rpc-password your-password \
--network testnet \
--api-port 9333Available networks: bitcoin, testnet, testnet4, signet, regtest