{"id":13823213,"url":"https://github.com/decred/dcrdata","last_synced_at":"2025-12-14T20:05:35.551Z","repository":{"id":37943543,"uuid":"82826361","full_name":"decred/dcrdata","owner":"decred","description":"Decred block explorer, with packages and apps for data collection and storage. Written in Go.","archived":false,"fork":false,"pushed_at":"2025-06-06T00:29:22.000Z","size":22409,"stargazers_count":130,"open_issues_count":108,"forks_count":129,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-07-08T16:47:14.030Z","etag":null,"topics":["blockchain","cryptocurrency","decred","json-api","mempool","rest-api"],"latest_commit_sha":null,"homepage":"https://dcrdata.decred.org/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-22T16:24:53.000Z","updated_at":"2025-06-06T00:29:25.000Z","dependencies_parsed_at":"2023-11-19T16:23:52.559Z","dependency_job_id":"c2e6d897-33de-4f6c-b33d-76a1291b54db","html_url":"https://github.com/decred/dcrdata","commit_stats":{"total_commits":1497,"total_committers":57,"mean_commits":"26.263157894736842","dds":0.7034068136272544,"last_synced_commit":"a3c03f6c7a24dbc1eceaf084c4190831c93c2bf7"},"previous_names":["dcrdata/dcrdata"],"tags_count":314,"template":false,"template_full_name":null,"purl":"pkg:github/decred/dcrdata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decred%2Fdcrdata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decred%2Fdcrdata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decred%2Fdcrdata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decred%2Fdcrdata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decred","download_url":"https://codeload.github.com/decred/dcrdata/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decred%2Fdcrdata/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265787586,"owners_count":23828458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","cryptocurrency","decred","json-api","mempool","rest-api"],"created_at":"2024-08-04T09:00:24.737Z","updated_at":"2025-12-14T20:05:34.704Z","avatar_url":"https://github.com/decred.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# dcrdata\n\n[![Build Status](https://github.com/decred/dcrdata/workflows/Build%20and%20Test/badge.svg)](https://github.com/decred/dcrdata/actions)\n[![Latest tag](https://img.shields.io/github/tag/decred/dcrdata.svg)](https://github.com/decred/dcrdata/tags)\n[![Go Report Card](https://goreportcard.com/badge/github.com/decred/dcrdata)](https://goreportcard.com/report/github.com/decred/dcrdata)\n[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)\n\n## Overview\n\ndcrdata is an original [Decred](https://www.decred.org/) block explorer, with\npackages and apps for data collection, presentation, and storage. The backend\nand middleware are written in Go. On the front end, Webpack enables the use of\nmodern javascript features, as well as SCSS for styling.\n\n- [dcrdata](#dcrdata)\n  - [Overview](#overview)\n  - [Release Status](#release-status)\n  - [Repository Overview](#repository-overview)\n  - [Requirements](#requirements)\n  - [Docker Support](#docker-support)\n  - [Building](#building)\n    - [Preparation](#preparation)\n    - [Package the Static Web Assets](#package-the-static-web-assets)\n    - [Building dcrdata with Go](#building-dcrdata-with-go)\n    - [Setting build version flags](#setting-build-version-flags)\n    - [Runtime Resources](#runtime-resources)\n  - [Updating](#updating)\n  - [Upgrading Instructions](#upgrading-instructions)\n    - [From v3.x or later](#from-v3x-or-later)\n    - [From v2.x or earlier](#from-v2x-or-earlier)\n  - [Getting Started](#getting-started)\n    - [Configuring PostgreSQL (**IMPORTANT!** Seriously, read this.)](#configuring-postgresql-important-seriously-read-this)\n    - [Creating the dcrdata Configuration File](#creating-the-dcrdata-configuration-file)\n    - [Using Environment Variables for Configuration](#using-environment-variables-for-configuration)\n    - [Indexing the Blockchain](#indexing-the-blockchain)\n    - [Starting dcrdata](#starting-dcrdata)\n    - [Hiding the PostgreSQL Settings Table](#hiding-the-postgresql-settings-table)\n    - [Running the Web Interface During Synchronization](#running-the-web-interface-during-synchronization)\n  - [System Hardware Requirements](#system-hardware-requirements)\n    - [dcrdata only (PostgreSQL on other host)](#dcrdata-only-postgresql-on-other-host)\n    - [dcrdata and PostgreSQL on same host](#dcrdata-and-postgresql-on-same-host)\n  - [dcrdata Daemon](#dcrdata-daemon)\n    - [Block Explorer](#block-explorer)\n  - [APIs](#apis)\n    - [Insight API](#insight-api)\n    - [dcrdata API](#dcrdata-api)\n      - [Endpoint List](#endpoint-list)\n  - [Important Note About Mempool](#important-note-about-mempool)\n  - [Command Line Utilities](#command-line-utilities)\n    - [rebuilddb2](#rebuilddb2)\n    - [scanblocks](#scanblocks)\n  - [Front End Development](#front-end-development)\n    - [CSS Guidelines](#css-guidelines)\n    - [HTML](#html)\n    - [Javascript](#javascript)\n    - [Web Performance](#web-performance)\n  - [Helper Packages](#helper-packages)\n  - [Internal-use Packages](#internal-use-packages)\n  - [Plans](#plans)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Release Status\n\nAlways run the Current release or on the Current stable branch. Do not use `master` in production.\n\n|             | Series  | Branch       | Latest release tag | `dcrd` RPC server version required |\n| ----------- | ------- | ------------ | ------------------ | ---------------------------------- |\n| Development | 6.1     | `master`     | N/A                | ^7.0.0 (dcrd v1.7 release)         |\n| Current     | 6.0     | `6.0-stable` | `release-v6.0`     | ^6.2.0 (dcrd v1.6 release)         |\n\n## Repository Overview\n\n```none\n../dcrdata                The main Go MODULE. See cmd/dcrdata for the explorer executable.\n├── api/types             The exported structures used by the dcrdata and Insight APIs.\n├── blockdata             Package blockdata is the primary data collection and\n|                           storage hub, and chain monitor.\n├── cmd\n│   └── dcrdata           MODULE for the dcrdata explorer executable.\n│       ├── api           dcrdata's own HTTP API\n│       │   └── insight   The Insight API\n│       ├── explorer      Powers the block explorer pages.\n│       ├── middleware    HTTP router middleware used by the explorer\n│       ├── notification  Manages dcrd notifications synchronous data collection.\n│       ├── public        Public resources for block explorer (css, js, etc.)\n│       └── views         HTML templates for block explorer\n├── db\n│   ├── cache             Package cache provides a caching layer that is used by dcrpg.\n│   ├── dbtypes           Package dbtypes with common data types.\n│   └── dcrpg             MODULE and package dcrpg providing PostgreSQL backend.\n├── dev                   Shell scripts for maintenance and deployment.\n├── docs                  Extra documentation.\n├── exchanges             MODULE and package for gathering data from public exchange APIs\n│   ├── rateserver        rateserver app, which runs an exchange bot for collecting\n│   |                       exchange rate data, and a gRPC server for providing this\n│   |                       data to multiple clients like dcrdata.\n|   └── ratesproto        Package dcrrates implementing a gRPC protobuf service for\n|                           communicating exchange rate data with a rateserver.\n├── explorer/types        Types used primarily by the explorer pages.\n├── gov                   MODULE for the on- and off-chain governance packages.\n│   ├── agendas           Package agendas defines a consensus deployment/agenda DB.\n│   └── politeia          Package politeia defines a Politeia proposal DB.\n│       ├── piclient      Package piclient provides functions for retrieving data\n|       |                   from the Politeia web API.\n│       └── types         Package types provides several JSON-tagged structs for\n|                           dealing with Politeia data exchange.\n├── mempool               Package mempool for monitoring mempool for transactions,\n|                           data collection, distribution, and storage.\n├── netparams             Package netparams defines the TCP port numbers for the\n|                           various networks (mainnet, testnet, simnet).\n├── pubsub                Package pubsub implements a websocket-based pub-sub server\n|   |                       for blockchain data.\n│   ├── democlient        democlient app provides an example for using psclient to\n|   |                       register for and receive messages from a pubsub server.\n│   ├── psclient          Package psclient is a basic client for the pubsub server.\n│   └── types             Package types defines types used by the pubsub client\n|                           and server.\n├── rpcutils              Package rpcutils contains helper types and functions for\n|                           interacting with a chain server via RPC.\n├── semver                Defines the semantic version types.\n├── stakedb               Package stakedb, for tracking tickets\n├── testutil\n│   ├── apiload           An HTTP API load testing application\n|   └── dbload            A DB load testing application\n└── txhelpers             Package txhelpers provides many functions and types for\n                            processing blocks, transactions, voting, etc.\n```\n\n## Requirements\n\n- [Go](https://golang.org) 1.20 or 1.21\n- [Node.js](https://nodejs.org/en/download/) 16.x or later. Node.js is only used\n  as a build tool, and is **not used at runtime**.\n- Running `dcrd` running with `--txindex`, and synchronized to the current best\n  block on the network. On startup, dcrdata will verify that the dcrd version is\n  compatible.\n- PostgreSQL 11+\n\n## Docker Support\n\nDockerfiles are provided for convenience, but NOT SUPPORTED. See [the Docker\ndocumentation](docs/docker.md) for more information. The supported dcrdata build\ninstructions are described below.\n\n## Building\n\nThe dcrdata build process comprises two general steps:\n\n1. Bundle the static web page assets with Webpack (via the `npm` tool).\n2. Build the `dcrdata` executable from the Go source files.\n\nThese steps are described in detail in the following sections.\n\nNOTE: The following instructions assume a Unix-like shell (e.g. bash).\n\n### Preparation\n\n- [Install Go](https://golang.org/doc/install)\n\n- Verify Go installation:\n\n  ```sh\n  go env GOROOT GOPATH\n  ```\n\n- Ensure `$GOPATH/bin` is on your `$PATH`.\n\n- Clone the dcrdata repository. It is conventional to put it under `GOPATH`, but\n  this is no longer necessary (or recommend) with Go modules. For example:\n\n  ```sh\n  git clone https://github.com/decred/dcrdata $HOME/go-work/github/decred/dcrdata\n  ```\n\n- [Install Node.js](https://nodejs.org/en/download/), which is required to lint\n  and package the static web assets.\n\nNote that none of the above is required at runtime.\n\n### Package the Static Web Assets\n\n[Webpack](https://webpack.js.org/), a JavaScript module bundler, is used to\ncompile and package the static assets in the `cmd/dcrdata/public` folder.\nNode.js' `npm` tool is used to install the required Node.js dependencies and\nbuild the bundled JavaScript distribution for deployment.\n\nFirst, install the build dependencies:\n\n```sh\ncd cmd/dcrdata\nnpm clean-install # creates node_modules folder fresh\n```\n\nThen, for production, build the webpack bundle:\n\n```sh\nnpm run build # creates public/dist folder\n```\n\nAlternatively, for development, `npm` can be made to watch for and integrate\nJavaScript source changes:\n\n```sh\nnpm run watch\n```\n\nSee [Front End Development](#front-end-development) for more information.\n\n### Building dcrdata with Go\n\nChange to the `cmd/dcrdata` folder and build:\n\n```sh\ncd cmd/dcrdata\ngo build -v\n```\n\nThe go tool will process the source code and automatically download\ndependencies. If the dependencies are configured correctly, there will be no\nmodifications to the `go.mod` and `go.sum` files.\n\nNote that performing the above commands with older versions of Go within\n`$GOPATH` may require setting `GO111MODULE=on`.\n\nAs a reward for reading this far, you may use the [build.sh](dev/build.sh)\nscript to mostly automate the build steps.\n\n### Setting build version flags\n\nBy default, the version string will be postfixed with \"-pre+dev\".  For example,\n`dcrdata version 5.1.0-pre+dev (Go version go1.12.7)`.  However, it may be\ndesirable to set the \"pre\" and \"dev\" values to different strings, such as\n\"beta\" or the actual commit hash.  To set these values, build with the\n`-ldflags` switch as follows:\n\n```sh\ngo build -v -ldflags \\\n  \"-X main.appPreRelease=beta -X main.appBuild=`git rev-parse --short HEAD`\"\n```\n\nThis produces a string like `dcrdata version 6.0.0-beta+750fd6c2 (Go version go1.16.2)`.\n\n### Runtime Resources\n\nThe config file, logs, and data files are stored in the application data folder,\nwhich may be specified via the `-A/--appdata` and `-b/--datadir` settings.\nHowever, the location of the config file may also be set with `-C/--configfile`.\nThe default paths for your system are shown in the `--help` description.\nIf encountering errors involving file system paths, check the permissions on these\nfolders to ensure that _the user running dcrdata_ is able to access these paths.\n\nThe \"public\" and \"views\" folders _must_ be in the same folder as the `dcrdata`\nexecutable. Set read-only permissions as appropriate.\n\n## Updating\n\nUpdate the repository (assuming you have `master` checked out in `GOPATH`):\n\n```sh\ncd $HOME/go-work/github/decred/dcrdata\ngit pull origin master\n```\n\nLook carefully for errors with `git pull`, and reset locally modified files if\nnecessary.\n\nNext, build `dcrdata` and bundle the web assets:\n\n```sh\ncd cmd/dcrdata\ngo build -v\nnpm clean-install\nnpm run build # or npm run watch\n```\n\nNote that performing the above commands with versions of Go prior to 1.16\nwithin `$GOPATH` may require setting `GO111MODULE=on`.\n\n## Upgrading Instructions\n\n### From v3.x or later\n\nNo special actions are required. Simply start the new dcrdata and automatic\ndatabase schema upgrades and table data patches will begin.\n\n### From v2.x or earlier\n\nThe database scheme change from dcrdata v2.x to v3.x does not permit an\nautomatic migration. The tables must be rebuilt from scratch:\n\n1. Drop the old dcrdata database, and create a new empty dcrdata database.\n\n   ```sql\n   -- Drop the old database.\n   DROP DATABASE dcrdata;\n\n   -- Create a new database with the same \"pguser\" set in the dcrdata.conf.\n   CREATE DATABASE dcrdata OWNER dcrdata;\n   ```\n\n2. Delete the dcrdata data folder (i.e. corresponding to the `datadir` setting).\n   By default, `datadir` is in `{appdata}/data`:\n\n   - Linux: `~/.dcrdata/data`\n   - Mac: `~/Library/Application Support/Dcrdata/data`\n   - Windows: `C:\\Users\\\u003cyour-username\u003e\\AppData\\Local\\Dcrdata\\data` (`%localappdata%\\Dcrdata\\data`)\n\n3. With dcrd synchronized to the network's best block, start dcrdata to begin\n   the initial block data sync.\n\n## Getting Started\n\n### Configuring PostgreSQL (**IMPORTANT!** Seriously, read this.)\n\nIt is crucial that you configure your PostgreSQL server for your hardware and\nthe dcrdata workload.\n\nRead [postgresql-tuning.conf](./db/dcrpg/postgresql-tuning.conf) carefully for\ndetails on how to make the necessary changes to your system. A helpful online\ntool for determining good settings for your system is called\n[PGTune](https://pgtune.leopard.in.ua/). Note that when using this tool,\nsubtract 1.5-2GB from your system RAM so dcrdata itself will have plenty of\nmemory. **DO NOT** simply use this file in place of your existing\npostgresql.conf. **DO NOT** simply copy and paste these settings into the\nexisting postgresql.conf. It is necessary to *edit the existing\npostgresql.conf*, reviewing all the settings to ensure the same configuration\nparameters are not set in two different places in the file (postgres will not\ncomplain).\n\nIf you tune PostgreSQL to fully utilize remaining RAM, you are limiting\nthe RAM available to the dcrdata process, which will increase as request\nvolume increases and its cache becomes fully utilized. Allocate sufficient\nmemory to dcrdata for your application, and use a reverse proxy such as nginx\nwith cache locking features to prevent simultaneous requests to the same\nresource.\n\nOn Linux, you may wish to use a unix domain socket instead of a TCP connection.\nThe path to the socket depends on the system, but it is commonly\n`/var/run/postgresql`. Just set this path in `pghost`.\n\n### Creating the dcrdata Configuration File\n\nBegin with the sample configuration file. With the default `appdata` directory\nfor the current user on Linux:\n\n```sh\ncp sample-dcrdata.conf ~/.dcrdata/dcrdata.conf\n```\n\nThen edit dcrdata.conf with your dcrd RPC settings. See the output of `dcrdata\n--help` for a list of all options and their default values.\n\n### Indexing the Blockchain\n\nIf dcrdata has not previously been run with the PostgreSQL database backend, it\nis necessary to perform a bulk import of blockchain data and generate table\nindexes. _This will be done automatically by `dcrdata`_ on a fresh startup.\n**Do NOT interrupt the initial sync or use the browser interface until it is\ncompleted.**\n\nNote that dcrdata requires that\n[dcrd](https://docs.decred.org/wallets/cli/dcrd-setup/) is\nrunning with some optional indexes enabled. By default, these indexes are not\nturned on when dcrd is installed. To enable them, set the following in\ndcrd.conf:\n\n```ini\ntxindex=1\n```\n\nIf these parameters are not set, dcrdata will be unable to retrieve transaction\ndetails and perform address searches, and will exit with an error mentioning\nthese indexes.\n\n### Starting dcrdata\n\nLaunch the dcrdata daemon and allow the databases to process new blocks.\nConcurrent synchronization of both stake and PostgreSQL databases is performed,\ntypically requiring between 1.5 to 8 hours. See [System Hardware\nRequirements](#System-Hardware-Requirements) for more information. Please reread\n[Configuring PostgreSQL (**IMPORTANT!** Seriously, read\nthis.)](#configuring-postgresql-important-seriously-read-this) of you have\nperformance issues.\n\nOn subsequent launches, only blocks new to dcrdata are processed.\n\n```sh\n./dcrdata    # don't forget to configure dcrdata.conf in the appdata folder!\n```\n\n**Do NOT interrupt the initial sync or use the browser interface until it is\ncompleted.** Follow the messages carefully, and if you are uncertain of the\ncurrent sync status, check system resource utilization. Interrupting the\ninitial sync can leave dcrdata and it's databases in an unrecoverable or\nsuboptimal state. The main steps of the initial sync process are:\n\n1. Initial block data import\n2. Indexing\n3. Spending transaction relationship updates\n4. Final DB analysis and indexing\n5. Catch-up to network in normal sync mode\n6. Populate charts historical data\n7. Update Pi repo and parse proposal records (git will be running)\n8. Final catch-up and UTXO cache pre-warming\n9. Update project fund data and then idle\n\nUnlike dcrdata.conf, which must be placed in the `appdata` folder or explicitly\nset with `-C`, the \"public\" and \"views\" folders _must_ be in the same folder as\nthe `dcrdata` executable.\n\n## System Hardware Requirements\n\nThe time required to sync varies greatly with system hardware and software\nconfiguration. The most important factor is the storage medium on the database\nmachine. An SSD (preferably NVMe, not SATA) is REQUIRED. The PostgreSQL\noperations are extremely disk intensive, especially during the initial\nsynchronization process. Both high throughput and low latencies for fast\nrandom accesses are essential.\n\n### dcrdata only (PostgreSQL on other host)\n\nWithout PostgreSQL, the dcrdata process can get by with:\n\n- 1 CPU core\n- 2 GB RAM\n- HDD with 8GB free space\n\n### dcrdata and PostgreSQL on same host\n\nThese specifications assume dcrdata and postgres are running on the same machine.\n\nMinimum:\n\n- 2 CPU core\n- 6 GB RAM\n- SSD with 120GB free space (no spinning hard drive for the DB!)\n\nRecommend:\n\n- 3+ CPU cores\n- 12+ GB RAM\n- NVMe SSD with 120 GB free space\n\n## dcrdata Daemon\n\nThe `cmd/dcrdata` folder contains the `main` package for the `dcrdata` app, which\nhas several components including:\n\n1. Block explorer (web interface).\n2. Blockchain monitoring and data collection.\n3. Mempool monitoring and reporting.\n4. Database backend interfaces.\n5. RESTful JSON API (custom and Insight) over HTTP(S).\n6. Websocket-based pub-sub server.\n7. Exchange rate bot and gRPC server.\n\n### Block Explorer\n\nAfter dcrdata syncs with the blockchain server via RPC, by default it will begin\nlistening for HTTP connections on `http://127.0.0.1:7777/`. This means it starts\na web server listening on IPv4 localhost, port 7777. Both the interface and port\nare configurable. The block explorer and the JSON APIs are both provided by the\nserver on this port.\n\nNote that while dcrdata can be started with HTTPS support, it is recommended to\nemploy a reverse proxy such as Nginx (\"engine x\"). See sample-nginx.conf for an\nexample Nginx configuration.\n\n## APIs\n\nThe dcrdata block explorer is exposed by two APIs: a Decred implementation of\nthe [Insight API](https://github.com/bitpay/insight-api), and its\nown JSON HTTP API. The Insight API uses the path prefix `/insight/api`. The\ndcrdata API uses the path prefix `/api`.\nFile downloads are served from the `/download` path.\n\n### Insight API\n\nThe [Insight API](https://github.com/bitpay/insight-api) is accessible via HTTP\nvia REST or WebSocket.\n\nSee the [Insight API documentation](docs/Insight_API_documentation.md) for\nfurther details.\n\n### dcrdata API\n\nThe dcrdata API is a REST API accessible via HTTP. To call the dcrdata API, use\nthe `/api` path prefix.\n\n#### Endpoint List\n\n| Best block           | Path                                 | Type                                  |\n| -------------------- | ------------------------------------ | ------------------------------------- |\n| Summary              | `/block/best?txtotals=[true\\|false]` | `types.BlockDataBasic`                |\n| Stake info           | `/block/best/pos`                    | `types.StakeInfoExtended`             |\n| Header               | `/block/best/header`                 | `dcrjson.GetBlockHeaderVerboseResult` |\n| Raw Header (hex)     | `/block/best/header/raw`             | `string`                              |\n| Hash                 | `/block/best/hash`                   | `string`                              |\n| Height               | `/block/best/height`                 | `int`                                 |\n| Raw Block (hex)      | `/block/best/raw`                    | `string`                              |\n| Size                 | `/block/best/size`                   | `int32`                               |\n| Subsidy              | `/block/best/subsidy`                | `types.BlockSubsidies`                |\n| Transactions         | `/block/best/tx`                     | `types.BlockTransactions`             |\n| Transactions Count   | `/block/best/tx/count`               | `types.BlockTransactionCounts`        |\n| Verbose block result | `/block/best/verbose`                | `dcrjson.GetBlockVerboseResult`       |\n\n| Block X (block index) | Path                  | Type                                  |\n| --------------------- | --------------------- | ------------------------------------- |\n| Summary               | `/block/X`            | `types.BlockDataBasic`                |\n| Stake info            | `/block/X/pos`        | `types.StakeInfoExtended`             |\n| Header                | `/block/X/header`     | `dcrjson.GetBlockHeaderVerboseResult` |\n| Raw Header (hex)      | `/block/X/header/raw` | `string`                              |\n| Hash                  | `/block/X/hash`       | `string`                              |\n| Raw Block (hex)       | `/block/X/raw`        | `string`                              |\n| Size                  | `/block/X/size`       | `int32`                               |\n| Subsidy               | `/block/best/subsidy` | `types.BlockSubsidies`                |\n| Transactions          | `/block/X/tx`         | `types.BlockTransactions`             |\n| Transactions Count    | `/block/X/tx/count`   | `types.BlockTransactionCounts`        |\n| Verbose block result  | `/block/X/verbose`    | `dcrjson.GetBlockVerboseResult`       |\n\n| Block H (block hash) | Path                       | Type                                  |\n| -------------------- | -------------------------- | ------------------------------------- |\n| Summary              | `/block/hash/H`            | `types.BlockDataBasic`                |\n| Stake info           | `/block/hash/H/pos`        | `types.StakeInfoExtended`             |\n| Header               | `/block/hash/H/header`     | `dcrjson.GetBlockHeaderVerboseResult` |\n| Raw Header (hex)     | `/block/hash/H/header/raw` | `string`                              |\n| Height               | `/block/hash/H/height`     | `int`                                 |\n| Raw Block (hex)      | `/block/hash/H/raw`        | `string`                              |\n| Size                 | `/block/hash/H/size`       | `int32`                               |\n| Subsidy              | `/block/best/subsidy`      | `types.BlockSubsidies`                |\n| Transactions         | `/block/hash/H/tx`         | `types.BlockTransactions`             |\n| Transactions count   | `/block/hash/H/tx/count`   | `types.BlockTransactionCounts`        |\n| Verbose block result | `/block/hash/H/verbose`    | `dcrjson.GetBlockVerboseResult`       |\n\n| Block range (X \u003c Y)                     | Path                      | Type                     |\n| --------------------------------------- | ------------------------- | ------------------------ |\n| Summary array for blocks on `[X,Y]`     | `/block/range/X/Y`        | `[]types.BlockDataBasic` |\n| Summary array with block index step `S` | `/block/range/X/Y/S`      | `[]types.BlockDataBasic` |\n| Size (bytes) array                      | `/block/range/X/Y/size`   | `[]int32`                |\n| Size array with step `S`                | `/block/range/X/Y/S/size` | `[]int32`                |\n\n| Transaction T (transaction id)       | Path                         | Type               |\n| ------------------------------------ | ---------------------------- | ------------------ |\n| Transaction details                  | `/tx/T?spends=[true\\|false]` | `types.Tx`         |\n| Transaction details w/o block info   | `/tx/trimmed/T`              | `types.TrimmedTx`  |\n| Inputs                               | `/tx/T/in`                   | `[]types.TxIn`     |\n| Details for input at index `X`       | `/tx/T/in/X`                 | `types.TxIn`       |\n| Outputs                              | `/tx/T/out`                  | `[]types.TxOut`    |\n| Details for output at index `X`      | `/tx/T/out/X`                | `types.TxOut`      |\n| Vote info (ssgen transactions only)  | `/tx/T/vinfo`                | `types.VoteInfo`   |\n| Ticket info (sstx transactions only) | `/tx/T/tinfo`                | `types.TicketInfo` |\n| Serialized bytes of the transaction  | `/tx/hex/T`                  | `string`           |\n| Same as `/tx/trimmed/T`              | `/tx/decoded/T`              | `types.TrimmedTx`  |\n\n| Transactions (batch)                                    | Path                        | Type                |\n| ------------------------------------------------------- | --------------------------- | ------------------- |\n| Transaction details (POST body is JSON of `types.Txns`) | `/txs?spends=[true\\|false]` | `[]types.Tx`        |\n| Transaction details w/o block info                      | `/txs/trimmed`              | `[]types.TrimmedTx` |\n\n| Address A                                                               | Path                            | Type                  |\n| ----------------------------------------------------------------------- | ------------------------------- | --------------------- |\n| Summary of last 10 transactions                                         | `/address/A`                    | `types.Address`       |\n| Number and value of spent and unspent outputs                           | `/address/A/totals`             | `types.AddressTotals` |\n| Verbose transaction result for last \u003cbr\u003e 10 transactions                | `/address/A/raw`                | `types.AddressTxRaw`  |\n| Summary of last `N` transactions                                        | `/address/A/count/N`            | `types.Address`       |\n| Verbose transaction result for last \u003cbr\u003e `N` transactions               | `/address/A/count/N/raw`        | `types.AddressTxRaw`  |\n| Summary of last `N` transactions, skipping `M`                          | `/address/A/count/N/skip/M`     | `types.Address`       |\n| Verbose transaction result for last \u003cbr\u003e `N` transactions, skipping `M` | `/address/A/count/N/skip/M/raw` | `types.AddressTxRaw`  |\n| Transaction inputs and outputs as a CSV formatted file.                 | `/download/address/io/A`        | CSV file              |\n\n| Treasury                                                          | Path                  | Type                        |\n| ----------------------------------------------------------------- | --------------------- | --------------------------- |\n| Current treasury info (e.g. spendable/immature/spent balance)     | `/treasury/balance`   | `dbtypes.TreasuryBalance`   |\n\n| Stake Difficulty (Ticket Price)        | Path                    | Type                               |\n| -------------------------------------- | ----------------------- | ---------------------------------- |\n| Current sdiff and estimates            | `/stake/diff`           | `types.StakeDiff`                  |\n| Sdiff for block `X`                    | `/stake/diff/b/X`       | `[]float64`                        |\n| Sdiff for block range `[X,Y] (X \u003c= Y)` | `/stake/diff/r/X/Y`     | `[]float64`                        |\n| Current sdiff separately               | `/stake/diff/current`   | `dcrjson.GetStakeDifficultyResult` |\n| Estimates separately                   | `/stake/diff/estimates` | `dcrjson.EstimateStakeDiffResult`  |\n\n| Ticket Pool                                                                                    | Path                                                  | Type                        |\n| ---------------------------------------------------------------------------------------------- | ----------------------------------------------------- | --------------------------- |\n| Current pool info (size, total value, and average price)                                       | `/stake/pool`                                         | `types.TicketPoolInfo`      |\n| Current ticket pool, in a JSON object with a `\"tickets\"` key holding an array of ticket hashes | `/stake/pool/full`                                    | `[]string`                  |\n| Pool info for block `X`                                                                        | `/stake/pool/b/X`                                     | `types.TicketPoolInfo`      |\n| Full ticket pool at block height _or_ hash `H`                                                 | `/stake/pool/b/H/full`                                | `[]string`                  |\n| Pool info for block range `[X,Y] (X \u003c= Y)`                                                     | `/stake/pool/r/X/Y?arrays=[true\\|false]`\u003csup\u003e\\*\u003c/sup\u003e | `[]apitypes.TicketPoolInfo` |\n\nThe full ticket pool endpoints accept the URL query `?sort=[true|false]` for\nrequesting the tickets array in lexicographical order. If a sorted list or list\nwith deterministic order is _not_ required, using `sort=false` will reduce\nserver load and latency. However, be aware that the ticket order will be random,\nand will change each time the tickets are requested.\n\n\u003csup\u003e\\*\u003c/sup\u003eFor the pool info block range endpoint that accepts the `arrays`\nurl query, a value of `true` will put all pool values and pool sizes into\nseparate arrays, rather than having a single array of pool info JSON objects.\nThis may make parsing more efficient for the client.\n\n| Votes and Agendas Info            | Path                  | Type                        |\n| --------------------------------- | --------------------- | --------------------------- |\n| The current agenda and its status | `/stake/vote/info`    | `dcrjson.GetVoteInfoResult` |\n| All agendas high level details    | `/agendas`            | `[]types.AgendasInfo`       |\n| Details for agenda {agendaid}     | `/agendas/{agendaid}` | `types.AgendaAPIResponse`   |\n\n| Mempool                                           | Path                      | Type                            |\n| ------------------------------------------------- | ------------------------- | ------------------------------- |\n| Ticket fee rate summary                           | `/mempool/sstx`           | `apitypes.MempoolTicketFeeInfo` |\n| Ticket fee rate list (all)                        | `/mempool/sstx/fees`      | `apitypes.MempoolTicketFees`    |\n| Ticket fee rate list (N highest)                  | `/mempool/sstx/fees/N`    | `apitypes.MempoolTicketFees`    |\n| Detailed ticket list (fee, hash, size, age, etc.) | `/mempool/sstx/details`   | `apitypes.MempoolTicketDetails` |\n| Detailed ticket list (N highest fee rates)        | `/mempool/sstx/details/N` | `apitypes.MempoolTicketDetails` |\n\n| Exchanges                         | Path                | Type                         |\n| ----------------------------------| --------------------| ---------------------------- |\n| Exchange data summary             | `/exchanges`        | `exchanges.ExchangeBotState` |\n| List of available currency codes  | `/exchanges/codes`  | `[]string`                   |\n\nExchange monitoring is off by default. Server must be started with\n`--exchange-monitor` to enable exchange data.\nThe server will set a default currency code. To use a different code, pass URL\nparameter `?code=[code]`. For example, `/exchanges?code=EUR`.\n\n| Other                           | Path                                          | Type                                    |\n| ------------------------------- | --------------------------------------------- | --------------------------------------- |\n| Status                          | `/status`                                     | `types.Status`                          |\n| Health (HTTP 200 or 503)        | `/status/happy`                               | `types.Happy`                           |\n| Coin Supply                     | `/supply`                                     | `types.CoinSupply`                      |\n| Coin Supply Circulating (Mined) | `/supply/circulating?dcr=[true\\|false]`       | `int` (default) or `float` (`dcr=true`) |\n| Endpoint list (always indented) | `/list`                                       | `[]string`                              |\n\nAll JSON endpoints accept the URL query `indent=[true|false]`. For example,\n`/stake/diff?indent=true`. By default, indentation is off. The characters to use\nfor indentation may be specified with the `indentjson` string configuration\noption.\n\n## Important Note About Mempool\n\nAlthough there is mempool data collection and serving, it is **very important**\nto keep in mind that the mempool in your node (dcrd) is not likely to be exactly\nthe same as other nodes' mempool. Also, your mempool is cleared out when you\nshutdown dcrd. So, if you have recently (e.g. after the start of the current\nticket price window) started dcrd, your mempool _will_ be missing transactions\nthat other nodes have.\n\n## Front End Development\n\nMake sure you have a recent version of [node and npm](https://nodejs.org/en/download/)\ninstalled.\n\nFrom the cmd/dcrdata directory, run the following command to install the node\nmodules.\n\n`npm clean-install`\n\nThis will create and install into a directory named `node_modules`.\n\nYou'll also want to run `npm clean-install` after merging changes from upstream.\nIt is run for you when you use the build script (`./dev/build.sh`).\n\nFor development, there's a webpack script that watches for file changes and\nautomatically bundles. To use it, run the following command in a separate\nterminal and leave it running while you work. You'll only use this command if\nyou are editing javascript files.\n\n`npm run watch`\n\nFor production, bundle assets via:\n\n`npm run build`\n\nYou will need to at least `build` if changes have been made. `watch` essentially\nruns `build` after file changes, but also performs some additional checks.\n\n### CSS Guidelines\n\nWebpack compiles SCSS to CSS while bundling. The `watch` script described above\nalso watches for changes in these files and performs linting to ensure [syntax\ncompliance](https://github.com/stylelint/stylelint-config-standard).\n\nBefore you write any CSS, see if you can achieve your goal by using existing\nclasses available in Bootstrap 4. This helps prevent our stylesheets from\ngetting bloated and makes it easier for things to work well across a wide range\nbrowsers \u0026 devices. Please take the time to [Read the\ndocs](https://getbootstrap.com/docs/4.1/getting-started/introduction/)\n\nNote there is a dark mode, so make sure things look good with the dark\nbackground as well.\n\n### HTML\n\nThe core functionality of dcrdata is server-side rendered in Go and designed to\nwork well with javascript disabled. For users with javascript enabled,\n[Turbolinks](https://github.com/turbolinks/turbolinks) creates a persistent\nsingle page application that handles all HTML rendering.\n\n.tmpl files are cached by the backend, and can be reloaded via running\n`killall -USR1 dcrdata` from the command line.\n\n### Javascript\n\nTo encourage code that is idiomatic to Turbolinks based execution environment,\njavascript based enhancements should use [Stimulus](https://stimulusjs.org/)\ncontrollers with corresponding actions and targets. Keeping things tightly\nscoped with controllers and modules helps to localize complexity and maintain a\nclean application lifecycle. When using events handlers, bind and **unbind**\nthem in the `connect` and `disconnect` function of controllers which executes\nwhen they get removed from the DOM.\n\n### Web Performance\n\nThe core functionality of dcrdata should perform well in low power device / high\nlatency scenarios (eg. a cheap smart phone with poor reception). This means that\nheavy assets should be lazy loaded when they are actually needed. Simple tasks\nlike checking a transaction or address should have a very fast initial page\nload.\n\n## Helper Packages\n\n`package dbtypes` defines the data types used by the DB backends to model the\nblock, transaction, and related blockchain data structures. Functions for\nconverting from standard Decred data types (e.g. `wire.MsgBlock`) are also\nprovided.\n\n`package rpcutils` includes helper functions for interacting with a\n`rpcclient.Client`.\n\n`package stakedb` defines the `StakeDatabase` and `ChainMonitor` types for\nefficiently tracking live tickets, with the primary purpose of computing ticket\npool value quickly. It uses the `database.DB` type from\n`github.com/decred/dcrd/database` with an ffldb storage backend from\n`github.com/decred/dcrd/database/ffldb`. It also makes use of the `stake.Node`\ntype from `github.com/decred/dcrd/blockchain/stake`. The `ChainMonitor` type\nhandles connecting new blocks and chain reorganization in response to notifications\nfrom dcrd.\n\n`package txhelpers` includes helper functions for working with the common types\n`dcrutil.Tx`, `dcrutil.Block`, `chainhash.Hash`, and others.\n\n## Internal-use Packages\n\nSome packages are currently designed only for internal\nuse by other dcrdata packages, but may be of general value in\nthe future.\n\n`blockdata` defines:\n\n- The `chainMonitor` type and its `BlockConnectedHandler()` method that handles\n  block-connected notifications and triggers data collection and storage.\n- The `BlockData` type and methods for converting to API types.\n- The `blockDataCollector` type and its `Collect()` and `CollectHash()` methods\n  that are called by the chain monitor when a new block is detected.\n- The `BlockDataSaver` interface required by `chainMonitor` for storage of\n  collected data.\n\n`dcrpg` defines:\n\n- The `ChainDB` type, which is the primary exported type from `dcrpg`, providing\n  an interface for a PostgreSQL database.\n- A large set of lower-level functions to perform a range of queries given a\n  `*sql.DB` instance and various parameters.\n- The internal package contains the raw SQL statements.\n\n`package mempool` defines a `MempoolMonitor` type that can monitor a node's\nmempool using the `OnTxAccepted` notification handler to send newly received\ntransaction hashes via a designated channel. Ticket purchases (SSTx) are\ntriggers for mempool data collection, which is handled by the\n`DataCollector` class, and data storage, which is handled by any number\nof objects implementing the `MempoolDataSaver` interface.\n\n## Plans\n\nSee the GitHub [issue trackers](https://github.com/decred/dcrdata/issues) and\nthe [project milestones](https://github.com/decred/dcrdata/milestones).\n\n## Contributing\n\nYes, please! **See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for details**, but\nhere's the gist of it:\n\n1. Fork the repo.\n2. Create a branch for your work (`git checkout -b cool-stuff`).\n3. Code something great.\n4. Commit and push to your repo.\n5. Create a [pull request](https://github.com/decred/dcrdata/compare).\n\n**DO NOT merge from master to your feature branch; rebase.**\n\nAlso, [come chat with us on Matrix](https://chat.decred.org/) in the\ndcrdata channel!\n\n## License\n\nThis project is licensed under the ISC License. See the [LICENSE](LICENSE) file\nfor details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecred%2Fdcrdata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecred%2Fdcrdata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecred%2Fdcrdata/lists"}