diff --git a/.arclint b/.arclint
--- a/.arclint
+++ b/.arclint
@@ -245,7 +245,10 @@
"include": [
"(\\.md$)"
],
- "exclude": "(^contrib/gitian-builder/)"
+ "exclude": [
+ "(^contrib/gitian-builder/)",
+ "(^modules/docs/chronik.e.cash/)"
+ ]
},
"lint-python-mypy": {
"type": "lint-python-mypy",
diff --git a/contrib/teamcity/build-configurations.yml b/contrib/teamcity/build-configurations.yml
--- a/contrib/teamcity/build-configurations.yml
+++ b/contrib/teamcity/build-configurations.yml
@@ -939,6 +939,13 @@
build_args:
- "PREVIEW_BUILD=next.preview.js"
+ preview-chronik.e.cash:
+ docker:
+ context: modules/
+ port: 3000
+ build_args:
+ - "NGINX_CONF=nginx-preview.conf"
+
preview-explorer:
docker:
context: web/explorer
diff --git a/modules/.dockerignore b/modules/.dockerignore
new file mode 100644
--- /dev/null
+++ b/modules/.dockerignore
@@ -0,0 +1,2 @@
+chronik-client/node_modules
+docs/chronik.e.cash/node_modules
diff --git a/modules/Dockerfile b/modules/Dockerfile
new file mode 100644
--- /dev/null
+++ b/modules/Dockerfile
@@ -0,0 +1,30 @@
+# Multi-stage
+# 1) Node image for building frontend assets
+# 2) nginx stage to serve frontend assets
+
+# Stage 1
+FROM node:20-buster-slim AS builder
+
+# First, copy chronik-client and install its dependencies at the same relative path
+WORKDIR /app/chronik-client
+COPY chronik-client/ .
+RUN npm ci
+
+# Then, copy and build docs
+WORKDIR /app/chronik.e.cash/
+COPY docs/chronik.e.cash/package.json .
+COPY docs/chronik.e.cash/package-lock.json .
+RUN npm ci
+COPY docs/chronik.e.cash/ .
+RUN npm run build
+
+# Stage 2
+FROM nginx
+
+ARG NGINX_CONF=nginx.conf
+
+COPY docs/chronik.e.cash/$NGINX_CONF /etc/nginx/conf.d/default.conf
+# Copy static assets from builder stage
+COPY --from=builder /app/chronik.e.cash/build /usr/share/nginx/html/
+# Containers run nginx with global directives and daemon off
+ENTRYPOINT ["nginx", "-g", "daemon off;"]
diff --git a/modules/chronik-client/typedoc.json b/modules/chronik-client/typedoc.json
--- a/modules/chronik-client/typedoc.json
+++ b/modules/chronik-client/typedoc.json
@@ -1,3 +1,5 @@
{
- "excludePrivate": true
+ "entryPoints": ["./index.ts"],
+ "excludePrivate": true,
+ "sourceLinkTemplate": "https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/{path}#L{line}"
}
diff --git a/modules/docs/chronik.e.cash/.abclatestversion.sample b/modules/docs/chronik.e.cash/.abclatestversion.sample
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/.abclatestversion.sample
@@ -0,0 +1 @@
+0.0.0
diff --git a/modules/docs/chronik.e.cash/.eslintrc.js b/modules/docs/chronik.e.cash/.eslintrc.js
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/.eslintrc.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2024 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+const headerArray = [
+ {
+ pattern:
+ '^ Copyright \\(c\\) [2][0-9]{3}([-][2][0-9]{3})? The Bitcoin developers$',
+ template: ` Copyright (c) ${new Date().getFullYear()} The Bitcoin developers`,
+ },
+ ' Distributed under the MIT software license, see the accompanying',
+ ' file COPYING or http://www.opensource.org/licenses/mit-license.php.',
+];
+module.exports = {
+ // root: true as this repo exists within a monorepo
+ // We only want these special next settings to be used in this repo
+ // https://github.com/vercel/next.js/issues/40687
+ root: true,
+ extends: 'next/core-web-vitals',
+ overrides: [
+ {
+ files: ['*.js'],
+ // This is the default parser of ESLint
+ parser: 'espree',
+ parserOptions: {
+ ecmaVersion: 2020,
+ },
+ },
+ ],
+ plugins: ['header'],
+ rules: {
+ 'header/header': [2, 'line', headerArray, 1],
+ },
+};
diff --git a/modules/docs/chronik.e.cash/.gitignore b/modules/docs/chronik.e.cash/.gitignore
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/.gitignore
@@ -0,0 +1,27 @@
+# Copyright (c) 2024 The Bitcoin developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+# Dependencies
+/node_modules
+
+# Production
+/build
+
+# Generated files
+.docusaurus
+.cache-loader
+
+# Misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# This file is generated in CI with the latest version of Bitcoin ABC
+.abclatestversion
diff --git a/modules/docs/chronik.e.cash/README.md b/modules/docs/chronik.e.cash/README.md
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/README.md
@@ -0,0 +1,13 @@
+# chronik.e.cash
+
+Documentation site with live methods for chronik and chronik-client.
+
+This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
+
+# Development
+
+The latest version of Bitcoin ABC is needed to generate appropriate download links. Docusaurus gets this information from the file `.abclatestversion`.
+
+In order to run docusaurus locally, you will need this file in place.
+
+`cp .abclatestversion.sample .abclatestversion`
diff --git a/modules/docs/chronik.e.cash/babel.config.js b/modules/docs/chronik.e.cash/babel.config.js
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/babel.config.js
@@ -0,0 +1,7 @@
+// Copyright (c) 2024 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+module.exports = {
+ presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
+};
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/00-download.mdx b/modules/docs/chronik.e.cash/docs/0-chronik-setup/00-download.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/00-download.mdx
@@ -0,0 +1,96 @@
+---
+sidebar_position: 1
+---
+
+# Download & Install Chronik
+
+Download Chronik for the right platform.
+
+:::warning
+This tutorial is about how to run a bitcoind instance with Chronik enabled.
+This requires a decent server and may take days to sync. Recommended for advanced users.
+You can already get started by using one of our pre-synced instances:
+
+- **If you want to know how to use `chronik-client` in your eCash apps**, go to [Chronik - JS/TS Client](../chronik-js/install).
+
+:::
+
+import CodeBlock from '@theme/CodeBlock';
+import version from '!!raw-loader!../../.abclatestversion';
+export const downloadUrl = 'https://download.bitcoinabc.org';
+export const files = {
+ linux: {
+ x86_64: `bitcoin-abc-${version}-x86_64-linux-gnu-chronik-experimental.tar.gz`,
+ arm: `bitcoin-abc-${version}-arm-linux-gnueabihf-chronik-experimental.tar.gz`,
+ aarch64: `bitcoin-abc-${version}-aarch64-linux-gnu-chronik-experimental.tar.gz`,
+ },
+ windows: {
+ win64: `bitcoin-abc-${version}-win64-setup-unsigned.exe`,
+ },
+};
+export const downloadUrls = {
+ linux: {
+ x86_64: `${downloadUrl}/${version}/linux/${files.linux.x86_64}`,
+ arm: `${downloadUrl}/${version}/linux/${files.linux.arm}`,
+ aarch64: `${downloadUrl}/${version}/linux/${files.linux.aarch64}`,
+ },
+ windows: {
+ win64: `${downloadUrl}/${version}/win/${files.windows.win64}`,
+ },
+};
+
+Download the right Bitcoin ABC Chronik build for your operating system:
+
+## Linux
+
+### Linux x86_64
+
+
+ Click here to download Bitcoin ABC Chronik for Linux x86_64
+
+
+
+ {`curl -O ${downloadUrls.linux.x86_64}
+tar xf ${files.linux.x86_64}
+rm ${files.linux.x86_64}`}
+
+
+### Linux ARM
+
+
+ Click here to download Bitcoin ABC Chronik for Linux ARM
+
+
+
+ {`curl -O ${downloadUrls.linux.arm}
+tar xf ${files.linux.arm}
+rm ${files.linux.arm}`}
+
+
+### Linux Aarch64
+
+
+ Click here to download Bitcoin ABC Chronik for Linux aarch64
+
+
+
+ {`curl -O ${downloadUrls.linux.aarch64}
+tar xf ${files.linux.aarch64}
+rm ${files.linux.aarch64}`}
+
+
+## Windows
+
+
+ Click here to download Bitcoin ABC Chronik for Windows
+
+
+
+ {`curl -O ${downloadUrls.windows.win64}
+tar xf ${files.windows.win64}
+rm ${files.windows.win64}`}
+
+
+## MacOS
+
+Chronik is currently not built by default for MacOS, but you can [build it from source yourself](build-chronik#macos).
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/01-setup-chronik.md b/modules/docs/chronik.e.cash/docs/0-chronik-setup/01-setup-chronik.md
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/01-setup-chronik.md
@@ -0,0 +1,119 @@
+---
+sidebar_position: 2
+---
+
+# Setup Chronik
+
+After downloading Chronik, you need to run it to setup an instance.
+
+:::warning
+This tutorial is about how to run a bitcoind instance with Chronik enabled.
+This requires a decent server and may take days to sync. Recommended for advanced users.
+You can already get started by using one of our pre-synced instances:
+
+- **If you want to know how to use `chronik-client` in your eCash apps**, go to [Chronik - JS/TS Client](/chronik-js/install).
+
+:::
+
+## Getting started
+
+Make sure you downloaded Bitcoin ABC Chronik in the [previous step](download). In there, you will find an executable `bitcoind`.
+
+To enable Chronik, simply pass `-chronik` as CLI argument:
+
+```bash
+./bitcoind -chronik
+```
+
+Alternatively, you can also set it in the bitcoin.conf file:
+
+```conf title="bitcoin.conf"
+chronik=1
+```
+
+:::note
+If you have a previously synced but un-indexed node, this will first re-sync Chronik with the node, which could take quite some time, usually 2-3 days.
+
+When initially syncing a node from Genesis, Chronik will slow down initial sync by at least a factor of 2-3x, depending on hardware. It is highly recommended to use a server with a fast SSD.
+
+We're continuously working on optimizing Chronik to bring down initial sync time.
+:::
+
+### Debug info
+
+It may be useful to display some extra info so you can ensure everything in Chronik is going well, it is recommended to turn this on initially:
+
+```bash
+./bitcoind -chronik -debug=chronik
+```
+
+```conf title="bitcoin.conf"
+chronik=1
+debug=chronik
+```
+
+### `-chronikbind`
+
+On mainnet, by default, Chronik is bound to port 8331 on `127.0.0.1` (IPv4) and `::1` (IPv6). If you want to change this, use the `-chronikbind` argument, here e.g. binding it to port 10000 on IPv4:
+
+```bash
+./bitcoind -chronik -chronikbind=127.0.0.1:10000
+```
+
+```conf title="bitcoin.conf"
+chronik=1
+chronikbind=127.0.0.1:10000
+```
+
+You can specify `-chronikbind` multiple times to bind to multiple hosts, here e.g. binding to both IPv4 and IPv6 on port 10000:
+
+```bash
+./bitcoind -chronik -chronikbind=127.0.0.1:10000 -chronikbind=[::1]:10000
+```
+
+```conf title="bitcoin.conf"
+chronik=1
+chronikbind=127.0.0.1:10000
+chronikbind=[::1]:10000
+```
+
+:::note
+Unlike the RPC interface, Chronik is designed to be openly available on the internet, so at this point in development, there's no username/password, no bearer token, cookie or whitelist available.
+:::
+
+### `-chroniktokenindex=0`
+
+By default, Chronik has SLP/ALP token indexing **enabled**. However, if you don't need token indexing, you can disable this by providing `-chroniktokenindex=0`.
+
+```bash
+./bitcoind -chronik -chroniktokenindex=0
+```
+
+:::danger
+If you previously had a token index, supplying `-chroniktokenindex=0` will immediately wipe the token index, and to get it back, you will have to run `-chronikreindex`, which can take a long time.
+:::
+
+:::tip
+Even if your app is XEC only, it is still highly recommended to have the token index enabled, as Chronik provides a lot of checks to prevent accidental token burning. Since many tokens used on eCash have actual value, this will avoid accidentally burning these tokens, e.g. when broadcasting txs, and it is recommended to ignore UTXOs with token values for XEC-only apps.
+:::
+
+### `-chronikreindex`
+
+Sometimes it is necessary to re-index only Chronik, e.g. if the database corrupted through an outage. Supply `-chronikreindex` to only reindex the Chronik database and to leave the node untouched.
+
+:::danger
+This will immediately wipe the Chronik database, and cannot be undone. You will have to wait for the index to sync again.
+:::
+
+:::tip
+Since the official release of Chronik, database upgrades for newer versions will be done automatically at startup, so you probably won't have to use this option too often.
+:::
+
+### `-chronikperfstats`
+
+If you want to help Bitcoin ABC optimizing Chronik, you can provide this flag when resyncing the node. It collects some performance statistics in the `/perf` folder, which will help us with development.
+
+```conf title="bitcoin.conf"
+chronik=1
+chronikperfstats=1
+```
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/02-host-chronik.md b/modules/docs/chronik.e.cash/docs/0-chronik-setup/02-host-chronik.md
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/02-host-chronik.md
@@ -0,0 +1,49 @@
+---
+sidebar_position: 3
+---
+
+# Host Chronik
+
+It is recommended to use a reverse-proxy to host Chronik, like [Apache](https://httpd.apache.org/) or [NGINX](https://www.nginx.com/).
+
+## NGINX
+
+Click [here](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/) to install NGINX, or if you are on Ubuntu, it is simply:
+
+```bash
+sudo apt update
+sudo apt install nginx
+```
+
+Update the NGINX config file, in this example Chronik will be hosted under /xec:
+
+```nginx title="/etc/nginx/sites-enabled/default"
+server {
+ server_name chronik.yourapp.com;
+
+ location /xec/ {
+ proxy_pass http://127.0.0.1:8331/;
+ proxy_set_header Host $http_host;
+ add_header "Access-Control-Allow-Origin" *;
+ add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
+ }
+
+ location /xec/ws {
+ proxy_pass http://127.0.0.1:8331/ws;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "Upgrade";
+ }
+}
+```
+
+## HTTPS Support
+
+To enable HTTPS support, you can use Certbot:
+
+```bash
+certbot --nginx -d chronik.yourapp.com
+```
+
+It will automatically generate TLS certificates and update your NGINX config to use them. When asked if you want to create redirects, it is recommended to set this to "yes"
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/03-congratulations.mdx b/modules/docs/chronik.e.cash/docs/0-chronik-setup/03-congratulations.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/03-congratulations.mdx
@@ -0,0 +1,65 @@
+---
+sidebar_position: 4
+---
+
+# Congratulations!
+
+Congratulations, you've successfully setup your own Chronik instance.
+
+Anything **unclear** or **buggy** in this tutorial? [Please report it in our Telegram Group](https://t.me/+LO-EuBnZiXQ5YTZi)!
+
+## Try it out!
+
+You can try out your Chronik instance by entering its URL here:
+
+import { useState } from 'react';
+import { ChronikClientNode } from 'chronik-client';
+import './03-congratulations.scss';
+
+export const GetBlockchainInfo = () => {
+ const [chronikUrl, setChronikUrl] = useState(
+ 'https://chronik-native1.fabien.cash',
+ );
+ const [blockchainInfo, setBlockchainInfo] = useState(undefined);
+ const [error, setError] = useState(undefined);
+ const getBlockchainInfo = async () => {
+ const client = new ChronikClientNode(chronikUrl);
+ try {
+ const info = await client.blockchainInfo();
+ console.log(info);
+ setBlockchainInfo(info);
+ setError(undefined);
+ } catch (ex) {
+ setError(ex);
+ }
+ };
+ return (
+
+ setChronikUrl(e.target.value)}
+ />
+
+
+
+
+
{error && `${error}`}
+
+ Tip block hash: {blockchainInfo?.tipHash}
+
+
+ Tip block height: {blockchainInfo?.tipHeight}
+
+
+
+ );
+};
+
+
+
+## What's next?
+
+Now you can use Chronik in your JS/TS app, [you can follow our instructions there](../chronik-js/install).
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/03-congratulations.scss b/modules/docs/chronik.e.cash/docs/0-chronik-setup/03-congratulations.scss
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/03-congratulations.scss
@@ -0,0 +1,42 @@
+// Copyright (c) 2024 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+.blockchain-info {
+ padding: 10px;
+ border-radius: 5px;
+ border: 1px solid var(--ifm-color-secondary-darker);
+ background-color: var(--ifm-color-info-contrast-background);
+
+ .url {
+ width: 100%;
+ font-size: 17px;
+ padding: 6px;
+ margin-bottom: 6px;
+ }
+
+ .query {
+ padding: 7px;
+ font-size: 19px;
+ font-weight: 700;
+ border-radius: 5px;
+ cursor: pointer;
+ color: #fff;
+ border: 1px solid #00abe7;
+ background-image: linear-gradient(270deg, #0074c2 0%, #273498 100%);
+ background-size: 200% auto;
+ &:hover {
+ background-position: right center;
+ -webkit-box-shadow: '0px 3px 10px -5px rgba(0, 0, 0, 0.75)';
+ -moz-box-shadow: '0px 3px 10px -5px rgba(0, 0, 0, 0.75)';
+ box-shadow: '0px 3px 10px -5px rgba(0, 0, 0, 0.75)';
+ }
+ }
+
+ .result {
+ margin-top: 10px;
+ span {
+ font-family: monospace;
+ }
+ }
+}
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/04-tune-chronik.md b/modules/docs/chronik.e.cash/docs/0-chronik-setup/04-tune-chronik.md
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/04-tune-chronik.md
@@ -0,0 +1,19 @@
+---
+sidebar_position: 4
+---
+
+# Tune Chronik
+
+You can tune Chronik to speed up indexing by changing the following parameters.
+
+:::warning
+This is advanced usage and it is recommended to leave these values at their default.
+Changing them may slow down indexing if used incorrectly.
+:::
+
+## TxNumCache
+
+When looking up the tx nums of spent txs, we utilize a TxNumCache to speed up indexing. By default, it requires 40MB of memory, but you may increase the numbers in the hopes of speeding up indexing if you have memory to spare.
+
+- `-chroniktxnumcachebuckets`: Increases the number of buckets used in the TxNumCache. Caution against setting this too high, it may slow down indexing because Chronik scans them linearly. Defaults to 10.
+- `-chroniktxnumcachebucketsize`: Increases the number of txs in a bucket in the TxNumCache. Defaults to 100000.
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/05-build-chronik.md b/modules/docs/chronik.e.cash/docs/0-chronik-setup/05-build-chronik.md
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/05-build-chronik.md
@@ -0,0 +1,94 @@
+---
+sidebar_position: 4
+---
+
+# Build Chronik
+
+You may want to build Chronik yourself, in case we don't provide a binary for that platform or when you want to customize the Chronik build.
+
+## UNIX/Linux
+
+### Install dependencies
+
+#### Rust
+
+Chronik is written in Rust. Follow the [instructions here](https://rustup.rs/) to install it.
+
+#### Build tools & libraries
+
+Install CMake and required libraries on your system:
+
+```bash
+sudo apt update
+sudo apt install bsdmainutils build-essential cmake libssl-dev libevent-dev lld ninja-build python3 libjemalloc-dev libboost-dev libprotobuf-dev protobuf-compiler
+```
+
+### Build (full)
+
+See remaining required dependencies [here](https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/doc/build-unix.md), and then run:
+
+```bash
+mkdir build
+cd build
+cmake -GNinja .. -DBUILD_BITCOIN_CHRONIK=on
+ninja
+```
+
+### Build (minimal)
+
+This only builds what's necessary to run Chronik:
+
+```bash
+mkdir build
+cd build
+cmake -GNinja .. -DBUILD_BITCOIN_CHRONIK=ON -DENABLE_UPNP=OFF -DENABLE_NATPMP=OFF -DBUILD_BITCOIN_WALLET=OFF -DBUILD_BITCOIN_QT=OFF -DBUILD_BITCOIN_ZMQ=OFF
+ninja
+```
+
+## MacOS
+
+### Install dependencies
+
+#### Rust
+
+Chronik is written in Rust. Follow the [instructions here](https://rustup.rs/) to install it.
+
+#### Preparation
+
+1. Install Xcode from the App Store
+2. Install the MacOS command line tools:
+
+ `xcode-select --install`
+
+ When the popup appears, click `Install`.
+
+3. Install [Homebrew](https://brew.sh).
+
+#### Build tools & Libraries
+
+Install build tools and required libraries on your system:
+
+```bash
+brew install ninja cmake jemalloc boost openssl protobuf
+```
+
+### Build (minimal)
+
+This only builds what's necessary to run Chronik:
+
+```bash
+mkdir build
+cd build
+cmake -GNinja .. -DBUILD_BITCOIN_CHRONIK=ON -DENABLE_UPNP=OFF -DENABLE_NATPMP=OFF -DBUILD_BITCOIN_WALLET=OFF -DBUILD_BITCOIN_QT=OFF -DBUILD_BITCOIN_ZMQ=OFF
+ninja
+```
+
+:::note
+On some OSX setups, RocksDB is causing linker issues. You can try setting `default-features = true` in the `rocksdb` dependency in `chronik/chronik-db/Cargo.toml`:
+
+```toml
+# Key-value database
+rocksdb = { version = "0.21", default-features = true }
+```
+
+:::
diff --git a/modules/docs/chronik.e.cash/docs/0-chronik-setup/_category_.json b/modules/docs/chronik.e.cash/docs/0-chronik-setup/_category_.json
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/0-chronik-setup/_category_.json
@@ -0,0 +1,8 @@
+{
+ "label": "Chronik - Setup Instance",
+ "position": 2,
+ "link": {
+ "type": "generated-index",
+ "description": "How to setup a Chronik instance. Note: This requires a decent server and may take days to sync. Recommended for advanced users."
+ }
+}
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/.gitignore b/modules/docs/chronik.e.cash/docs/1-chronik-js/.gitignore
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/.gitignore
@@ -0,0 +1,2 @@
+# This is generated automatically by typedoc, don't commit it
+/api
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/00-install.md b/modules/docs/chronik.e.cash/docs/1-chronik-js/00-install.md
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/00-install.md
@@ -0,0 +1,15 @@
+---
+sidebar_position: 1
+---
+
+# Install
+
+Installing `chronik-client` is as simple as running this on either `npm` or `yarn`:
+
+```bash
+npm install chronik-client --save
+```
+
+```bash
+yarn add chronik-client
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/01-connect.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/01-connect.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/01-connect.mdx
@@ -0,0 +1,33 @@
+---
+sidebar_position: 2
+---
+
+# Connect
+
+Connect to a Chronik node via `chronik-client`.
+
+Import `ChronikClientNode` (soon to become `ChronikClient`) and provide it the Chronik URL in the constructor:
+
+```tsx
+import { ChronikClientNode } from 'chronik-client';
+const chronik = new ChronikClientNode('https://chronik-native1.fabien.cash');
+```
+
+## Try it out!
+
+You can try it out in this React component:
+
+```jsx live
+function DemoConnect() {
+ return (
+ {
+ const chronik = new ChronikClientNode(
+ 'https://chronik-native1.fabien.cash',
+ );
+ return await chronik.blockchainInfo();
+ }}
+ />
+ );
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/02-blockchain.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/02-blockchain.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/02-blockchain.mdx
@@ -0,0 +1,49 @@
+---
+sidebar_position: 3
+---
+
+# Blockchain
+
+Access the blockchain using Chronik
+
+## `blockchainInfo()`
+
+Fetch current info of the blockchain, such as tip hash and height.
+
+See [blockchainInfo](api/classes/ChronikClientNode#blockchaininfo) API docs.
+
+```jsx live
+function DemoBlockchainInfo() {
+ return (
+ {
+ const chronik = new ChronikClientNode(
+ 'https://chronik-native1.fabien.cash',
+ );
+ return await chronik.blockchainInfo();
+ }}
+ />
+ );
+}
+```
+
+## `chronikInfo()`
+
+Fetch info about the current running chronik server.
+
+See [chronikInfo](api/classes/ChronikClientNode#chronikinfo) API docs.
+
+```jsx live
+function DemoChronikInfo() {
+ return (
+ {
+ const chronik = new ChronikClientNode(
+ 'https://chronik-native1.fabien.cash',
+ );
+ return await chronik.chronikInfo();
+ }}
+ />
+ );
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/03-blocks.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/03-blocks.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/03-blocks.mdx
@@ -0,0 +1,49 @@
+---
+sidebar_position: 4
+---
+
+# Blocks
+Access blocks using Chronik
+
+## `blocks(hashOrHeight)`
+
+Fetch the block given hash or height.
+
+See [blocks](api/classes/ChronikClientNode#blocks) API docs.
+
+```jsx live
+function DemoBlock() {
+ return {
+ return await chronik.block(
+ "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
+ }} />;
+}
+```
+
+## `blockTxs(hashOrHeight, page, pageSize)`
+
+Fetch the tx history of a block given hash or height. `page` and `pageSize` is optional.
+
+See [blockTxs](api/classes/ChronikClientNode#blocktxs) API docs.
+
+```jsx live
+function DemoBlockTxs() {
+ return {
+ return await chronik.blockTxs(0);
+ }} />;
+}
+```
+
+## `blocks(startHeight, endHeight)`
+
+Fetch block info of a range of blocks. `startHeight` and `endHeight` are inclusive ranges.
+
+See [blocks](api/classes/ChronikClientNode#blocks) API docs.
+
+```jsx live
+function DemoBlocks() {
+ return {
+ return await chronik.blocks(50, 52);
+ }} />;
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/04-txs.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/04-txs.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/04-txs.mdx
@@ -0,0 +1,36 @@
+---
+sidebar_position: 5
+---
+
+# Transactions
+Access transactions using Chronik
+
+## `tx(txid)`
+
+Fetch tx details given the txid, includes token info.
+
+See [tx](api/classes/ChronikClientNode#tx) API docs.
+
+```jsx live
+function DemoTx() {
+ return {
+ return await chronik.tx(
+ "cdcdcdcdcdc9dda4c92bb1145aa84945c024346ea66fd4b699e344e45df2e145");
+ }} />;
+}
+```
+
+## `rawTx(hashOrHeight, page, pageSize)`
+
+Fetch the raw tx bytes given the txid.
+
+See [rawTx](api/classes/ChronikClientNode#rawtx) API docs.
+
+```jsx live
+function DemoRawTx() {
+ return {
+ return await chronik.rawTx(
+ "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
+ }} />;
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/05-addresses.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/05-addresses.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/05-addresses.mdx
@@ -0,0 +1,75 @@
+---
+sidebar_position: 6
+---
+
+# Scripts & Addresses
+Access scripts & addresses and using Chronik.
+
+## `address(address)`
+
+Return an object that can be used to fetch address data from Chronik in a fluent Interface.
+
+See [address](api/classes/ChronikClientNode#address) API docs.
+
+```jsx live
+function DemoAddress() {
+ return {
+ // Some address with little history
+ return await chronik
+ .address("ecash:qr3ax9kpca8qkgtwk0cdqdhnprsgfsq3xu2dx56fmw")
+ .history(0);
+ }} />;
+}
+```
+
+## `script(type, payload)`
+
+Return an object that can be used to fetch script data from Chronik in a fluent Interface.
+
+See [script](api/classes/ChronikClientNode#script) API docs.
+
+```jsx live
+function DemoScript() {
+ return {
+ // Same address, but using the Public-Key-Hash
+ return await chronik
+ .script("p2pkh", "e3d316c1c74e0b216eb3f0d036f308e084c01137")
+ .history(0);
+ }} />;
+}
+```
+
+## `history(pageOffset, pageSize)`
+
+Fetch the tx history of a script or address, from latest to earliest.
+
+See [history](api/classes/ScriptEndpointInNode#history) API docs.
+
+```jsx live
+function DemoAddressHistory() {
+ return {
+ // IFP address
+ return await chronik.address("ecash:prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07")
+ .history(300, 2);
+ }} />;
+}
+```
+
+## `utxos()`
+
+Fetch the utxos of a script or address.
+
+See [utxos](api/classes/ScriptEndpointInNode#utxos) API docs.
+
+```jsx live
+function DemoScriptUtxos() {
+ return {
+ // Genesis PK utxos
+ return await chronik
+ .script("p2pk", "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a6" +
+ "7962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c" +
+ "384df7ba0b8d578a4c702b6bf11d5f")
+ .utxos();
+ }} />;
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/06-tokens.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/06-tokens.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/06-tokens.mdx
@@ -0,0 +1,112 @@
+---
+sidebar_position: 7
+---
+
+# Tokens
+Access tokens using Chronik.
+
+:::note
+This page only lists token-specific endpoints.
+All other APIs (tx, history, utxos, etc.) also contain token data where applicable.
+:::
+
+## `token(tokenId)`
+
+Return token info for the given tokenId
+
+See [token](api/classes/ChronikClientNode#token) API docs.
+
+```jsx live
+function DemoToken() {
+ return {
+ // CRD token
+ return await chronik
+ .token("cdcdcdcdcdc9dda4c92bb1145aa84945c024346ea66fd4b699e344e45df2e145");
+ }} />;
+}
+```
+
+## `tokenId(tokenId)`
+
+Return an object that can be used to fetch token data from Chronik in a fluent interface.
+
+See [tokenId](api/classes/ChronikClientNode#tokenid) API docs.
+
+```jsx live
+function DemoTokenId() {
+ return {
+ // CRD Genesis is first
+ return await chronik
+ .tokenId("cdcdcdcdcdc9dda4c92bb1145aa84945c024346ea66fd4b699e344e45df2e145")
+ .confirmedTxs(0, 1);
+ }} />;
+}
+```
+
+## `history(pageOffset, pageSize)`
+
+Fetch the tx history of a Token ID, from latest to earliest.
+
+See [history](api/classes/TokenIdEndpoint#history) API docs.
+
+```jsx live
+function DemoTokenIdHistory() {
+ return {
+ // The latest CRD tx
+ return await chronik
+ .tokenId("cdcdcdcdcdc9dda4c92bb1145aa84945c024346ea66fd4b699e344e45df2e145")
+ .history(0, 1);
+ }} />;
+}
+```
+
+## `confirmedTxs(pageOffset, pageSize)`
+
+Fetch the confirmed txs of a Token ID, from first to last.
+
+See [confirmedTxs](api/classes/TokenIdEndpoint#confirmedtxs) API docs.
+
+```jsx live
+function DemoTokenIdConfirmedTxs() {
+ return {
+ // CRD GENESIS
+ return await chronik
+ .tokenId("cdcdcdcdcdc9dda4c92bb1145aa84945c024346ea66fd4b699e344e45df2e145")
+ .confirmedTxs(0, 1);
+ }} />;
+}
+```
+
+## `unconfirmedTxs()`
+
+Fetch the unconfirmed txs of a Token ID.
+
+See [unconfirmedTxs](api/classes/TokenIdEndpoint#unconfirmedtxs) API docs.
+
+```jsx live
+function DemoTokenIdUnconfirmedTxs() {
+ return {
+ // Grumpy token txs in mempool
+ return await chronik
+ .tokenId("fb4233e8a568993976ed38a81c2671587c5ad09552dedefa78760deed6ff87aa")
+ .unconfirmedTxs();
+ }} />;
+}
+```
+
+## `utxos()`
+
+Fetch the utxos of a Token ID.
+
+See [utxos](api/classes/TokenIdEndpoint#utxos) API docs.
+
+```jsx live
+function DemoTokenIdUtxos() {
+ return {
+ // Some CRD UTXO
+ return (await chronik
+ .tokenId("cdcdcdcdcdc9dda4c92bb1145aa84945c024346ea66fd4b699e344e45df2e145")
+ .utxos()).utxos[0];
+ }} />;
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/07-broadcast-tx.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/07-broadcast-tx.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/07-broadcast-tx.mdx
@@ -0,0 +1,45 @@
+---
+sidebar_position: 8
+---
+
+# Broadcast Transactions
+Broadcast transactions onto the blockchain
+
+## `broadcastTx(rawTx, skipTokenChecks?)`
+
+Broadcast the given raw tx onto the network; by default will verify that no tokens are unintentionally burned.
+Can be disabled with `skipTokenChecks` set to `true`, but this is not recommended.
+
+See [broadcastTx](api/classes/ChronikClientNode#broadcasttx) API docs.
+
+```jsx live
+function DemoBroadcastTx() {
+ return {
+ // Tx tries to burn the first CRD mint baton
+ return await chronik.broadcastTx(
+ "000000000145e1f25de444e399b6d46fa66e3424c04549a85a14b12bc9a4ddc9" +
+ "cdcdcdcdcd0100000000000000000000000000");
+ }} />;
+}
+```
+
+## `broadcastTxs(rawTxs, skipTokenChecks?)`
+
+Broadcast the given raw txs onto the network, by defailt only if all of them pass the token checks
+that verify that no tokens are unintentionally burned.
+Can be disabled with `skipTokenChecks` set to `true`, but this is not recommended.
+
+See [broadcastTxs](api/classes/ChronikClientNode#broadcasttxs) API docs.
+
+```jsx live
+function DemoBroadcastTxs() {
+ return {
+ // Txs try to burn the first CRD mint baton
+ return await chronik.broadcastTxs(
+ ["000000000145e1f25de444e399b6d46fa66e3424c04549a85a14b12bc9a4ddc9" +
+ "cdcdcdcdcd0100000000000000000000000000",
+ "010000000145e1f25de444e399b6d46fa66e3424c04549a85a14b12bc9a4ddc9" +
+ "cdcdcdcdcd0100000000000000000000000000"]);
+ }} />;
+}
+```
diff --git a/modules/docs/chronik.e.cash/docs/1-chronik-js/08-websocket.mdx b/modules/docs/chronik.e.cash/docs/1-chronik-js/08-websocket.mdx
new file mode 100644
--- /dev/null
+++ b/modules/docs/chronik.e.cash/docs/1-chronik-js/08-websocket.mdx
@@ -0,0 +1,39 @@
+---
+sidebar_position: 9
+---
+
+# WebSocket
+Subscribe to updates coming from the blockchain.
+
+## `ws(wsConfig)`
+
+See [ws](api/classes/ChronikClientNode#ws) API docs.
+
+See [WsEndpoint_InNode](api/classes/WsEndpoint_InNode#methods) for a reference of all the subscription methods.
+
+```jsx live
+function DemoWebSocket() {
+ const [logs, setLogs] = useState([]);
+ useEffect(() => {
+ const addToLog = msg => {
+ msg.timestamp = new Date().toISOString();
+ console.log(msg);
+ setLogs([...logs, JSON.stringify(msg)])
+ };
+ const ws = chronik.ws({
+ onMessage: addToLog,
+ onConnect: addToLog,
+ onReconnect: addToLog,
+ onError: addToLog,
+ onEnd: addToLog,
+ });
+ // Send block updates
+ ws.subscribeToBlocks();
+ // Random address that seems to have a lot of traffic
+ ws.subscribeToAddress("ecash:qryzw7gteszy8jgsejjchlwjg7lctxpwjgllx92x9j");
+ // This can be awaited
+ ws.waitForOpen();
+ }, []);
+ return logs.map((log, idx) =>