|
| 1 | + |
| 2 | +<!-- (SPDX-License-Identifier: CC-BY-4.0) --> <!-- Ensure there is a newline before, and after, this line --> |
| 3 | + |
| 4 | +# Hyperledger Explorer [![join the chat][rocketchat-image]][rocketchat-url] [](https://stackoverflow.com/search?tab=newest&q=hyperledger%20explorer%20hyperledger-explorer) |
| 5 | + |
| 6 | +[rocketchat-url]:https://chat.hyperledger.org/channel/hyperledger-explorer |
| 7 | +[rocketchat-image]:https://open.rocket.chat/images/join-chat.svg |
| 8 | +[](https://github.com/hyperledger/blockchain-explorer/releases) |
| 9 | +[](https://hub.docker.com/r/hyperledger/explorer) |
| 10 | +<br /> |
| 11 | +[](https://dev.azure.com/Hyperledger/blockchain-explorer/_build/latest?definitionId=41&branchName=main) |
| 12 | +[](https://bestpractices.coreinfrastructure.org/projects/2710) |
| 13 | +[](https://blockchain-explorer.readthedocs.io/en/main/?badge=main) |
| 14 | +[](https://lgtm.com/projects/g/hyperledger/blockchain-explorer/context:javascript) |
| 15 | +[](https://lgtm.com/projects/g/hyperledger/blockchain-explorer/alerts/) |
| 16 | +[](https://sonarcloud.io/dashboard?id=hyperledger_blockchain-explorer) |
| 17 | +<!-- badges --> |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +Hyperledger Explorer is a simple, powerful, easy-to-use, well maintained, open source utility to browse activity on the underlying blockchain network. Users have the ability to configure and build Hyperledger Explorer on MacOS and Ubuntu. |
| 22 | + |
| 23 | +**Update!** Hyperledger Explorer now can be used with [**Hyperledger Iroha**](https://github.com/hyperledger/iroha). For Iroha support, please switch to [iroha-integration](../../tree/iroha-integration) branch and read this [README](../../tree/iroha-integration/iroha) for instructions on how to use it. |
| 24 | + |
| 25 | + |
| 26 | +# Release Notes |
| 27 | + |
| 28 | +| Hyperledger Explorer Version | Fabric Version Supported | NodeJS Version Supported | |
| 29 | +| -- | -- | -- | |
| 30 | +| <b>[v1.1.6](release_notes/v1.1.6.md)</b> (Jun 06, 2021) | [v1.4 to v2.3](https://hyperledger-fabric.readthedocs.io/en/release-2.3) | [^12.13.1, ^14.13.1](https://nodejs.org/en/download/releases) | |
| 31 | +| <b>[v1.1.5](release_notes/v1.1.5.md)</b> (Apr 20, 2021) | [v1.4 to v2.3](https://hyperledger-fabric.readthedocs.io/en/release-2.3) | [^12.13.1, ^14.13.1](https://nodejs.org/en/download/releases) | |
| 32 | +| <b>[v1.1.4](release_notes/v1.1.4.md)</b> (Jan 29, 2021) | [v1.4 to v2.2](https://hyperledger-fabric.readthedocs.io/en/release-2.2) | [^12.13.1, ^14.13.1](https://nodejs.org/en/download/releases) | |
| 33 | +| <b>[v1.1.3](release_notes/v1.1.3.md)</b> (Sep 28, 2020) | [v1.4.0 to v2.2.0](https://hyperledger-fabric.readthedocs.io/en/release-2.2) | [12.16.x](https://nodejs.org/en/download/releases) | |
| 34 | +| <b>[v1.1.2](release_notes/v1.1.2.md)</b> (Aug 12, 2020) | [v1.4.0 to v2.2.0](https://hyperledger-fabric.readthedocs.io/en/release-2.2) | [12.16.x](https://nodejs.org/en/download/releases) | |
| 35 | +| <b>[v1.1.1](release_notes/v1.1.1.md)</b> (Jul 17, 2020) | [v1.4.0 to v2.1.1](https://hyperledger-fabric.readthedocs.io/en/release-2.1) | [12.16.x](https://nodejs.org/en/download/releases) | |
| 36 | +| <b>[v1.1.0](release_notes/v1.1.0.md)</b> (Jul 01, 2020) | [v1.4.0 to v2.1.1](https://hyperledger-fabric.readthedocs.io/en/release-2.1) | [12.16.x](https://nodejs.org/en/download/releases) | |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +There are 2 options to get Explorer started. Following are the software dependencies required for each option. |
| 41 | +And if you want to refer more detail of each configuration, please refer [README-CONFIG.md](README-CONFIG.md). |
| 42 | + |
| 43 | +# Quick start (using Docker) |
| 44 | + |
| 45 | +## Prerequisites |
| 46 | + |
| 47 | +* Docker |
| 48 | +* Docker Compose |
| 49 | + * **Note:** |
| 50 | + The following docker images are automatically pulled from Docker Hub when starting docker-compose. |
| 51 | + |
| 52 | + * [Hyperledger Explorer docker repository](https://hub.docker.com/r/hyperledger/explorer/) |
| 53 | + * [Hyperledger Explorer PostgreSQL docker repository](https://hub.docker.com/r/hyperledger/explorer-db) |
| 54 | + |
| 55 | +## Start Hyperledger Fabric network |
| 56 | + |
| 57 | +In this guide, we assume that you've already started test network by following [Hyperledger Fabric official tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html). |
| 58 | + |
| 59 | +## Configure |
| 60 | + |
| 61 | +* Copy the following files from repository |
| 62 | + |
| 63 | + - [docker-compose.yaml](https://github.com/hyperledger/blockchain-explorer/blob/main/docker-compose.yaml) |
| 64 | + - [examples/net1/connection-profile/test-network.json](https://github.com/hyperledger/blockchain-explorer/blob/main/examples/net1/connection-profile/test-network.json) |
| 65 | + - [examples/net1/config.json](https://github.com/hyperledger/blockchain-explorer/blob/main/examples/net1/config.json) |
| 66 | + |
| 67 | + |
| 68 | + ``` |
| 69 | + $ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json |
| 70 | + $ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile |
| 71 | + $ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml |
| 72 | + ``` |
| 73 | + |
| 74 | +* Copy entire crypto artifact directory (e.g. crypto-config/, organizations/) from your fabric network |
| 75 | + |
| 76 | +* Now you should have the following files and directory structure. |
| 77 | + |
| 78 | + ``` |
| 79 | + docker-compose.yaml |
| 80 | + config.json |
| 81 | + connection-profile/test-network.json |
| 82 | + organizations/ordererOrganizations/ |
| 83 | + organizations/peerOrganizations/ |
| 84 | + ``` |
| 85 | +
|
| 86 | +* Edit network name and path to volumes to be mounted on Explorer container (docker-compose.yaml) to align with your environment |
| 87 | +
|
| 88 | + ```yaml |
| 89 | + networks: |
| 90 | + mynetwork.com: |
| 91 | + external: |
| 92 | + name: net_test |
| 93 | +
|
| 94 | + ... |
| 95 | +
|
| 96 | + services: |
| 97 | + explorer.mynetwork.com: |
| 98 | +
|
| 99 | + ... |
| 100 | +
|
| 101 | + volumes: |
| 102 | + - ./config.json:/opt/explorer/app/platform/fabric/config.json |
| 103 | + - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile |
| 104 | + - ./organizations:/tmp/crypto |
| 105 | + - walletstore:/opt/explorer/wallet |
| 106 | + ``` |
| 107 | +
|
| 108 | +* When you connect Explorer to your fabric network through bridge network, you need to set DISCOVERY_AS_LOCALHOST to false for disabling hostname mapping into localhost. |
| 109 | +
|
| 110 | + ```yaml |
| 111 | + services: |
| 112 | +
|
| 113 | + ... |
| 114 | +
|
| 115 | + explorer.mynetwork.com: |
| 116 | +
|
| 117 | + ... |
| 118 | +
|
| 119 | + environment: |
| 120 | + - DISCOVERY_AS_LOCALHOST=false |
| 121 | + ``` |
| 122 | +
|
| 123 | +* Edit path to admin certificate and secret key in the connection profile (test-network.json). You need to specify with the absolute path on Explorer container. |
| 124 | +
|
| 125 | + ```json |
| 126 | + "organizations": { |
| 127 | + "Org1MSP": { |
| 128 | + "adminPrivateKey": { |
| 129 | + "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk" |
| 130 | + ``` |
| 131 | +
|
| 132 | +## Start container services |
| 133 | +
|
| 134 | +* Run the following to start up explore and explorer-db services after starting your fabric network: |
| 135 | +
|
| 136 | + ```shell |
| 137 | + $ docker-compose up -d |
| 138 | + ``` |
| 139 | +
|
| 140 | +## Clean up |
| 141 | +
|
| 142 | +* To stop services without removing persistent data, run the following: |
| 143 | +
|
| 144 | + ```shell |
| 145 | + $ docker-compose down |
| 146 | + ``` |
| 147 | +
|
| 148 | +* In the docker-compose.yaml, two named volumes are allocated for persistent data (for Postgres data and user wallet), if you would like to clear these named volumes up, run the following: |
| 149 | +
|
| 150 | + ```shell |
| 151 | + $ docker-compose down -v |
| 152 | + ``` |
| 153 | +
|
| 154 | +
|
| 155 | +
|
| 156 | +# Quick start (using codebase) |
| 157 | +
|
| 158 | +## Prerequisites |
| 159 | +
|
| 160 | +* Nodejs 10 and 12 (10.19 and 12.16 tested) |
| 161 | +* PostgreSQL 9.5 or greater |
| 162 | +* [jq](https://stedolan.github.io/jq) |
| 163 | +* Linux-based operating system, such as Ubuntu or MacOS |
| 164 | +* golang (optional) |
| 165 | + * For e2e testing |
| 166 | +
|
| 167 | +## Start Hyperledger Fabric network |
| 168 | +
|
| 169 | +In this guide, we assume that you've already started test network by following [Hyperledger Fabric official tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html). |
| 170 | +
|
| 171 | +## Clone GIT Repository |
| 172 | +
|
| 173 | +Clone this repository to get the latest using the following command. |
| 174 | +
|
| 175 | +```shell |
| 176 | +$ git clone https://github.com/hyperledger/blockchain-explorer.git |
| 177 | +$ cd blockchain-explorer |
| 178 | +``` |
| 179 | + |
| 180 | +## Database Setup |
| 181 | + |
| 182 | +``` |
| 183 | +$ cd blockchain-explorer/app |
| 184 | +``` |
| 185 | + |
| 186 | +* Modify `app/explorerconfig.json` to update PostgreSQL database settings. |
| 187 | + |
| 188 | + ```json |
| 189 | + "postgreSQL": { |
| 190 | + "host": "127.0.0.1", |
| 191 | + "port": "5432", |
| 192 | + "database": "fabricexplorer", |
| 193 | + "username": "hppoc", |
| 194 | + "passwd": "password" |
| 195 | + } |
| 196 | + ``` |
| 197 | + |
| 198 | + * Another alternative to configure database settings is to use environment variables, example of settings: |
| 199 | + |
| 200 | + ```shell |
| 201 | + export DATABASE_HOST=127.0.0.1 |
| 202 | + export DATABASE_PORT=5432 |
| 203 | + export DATABASE_DATABASE=fabricexplorer |
| 204 | + export DATABASE_USERNAME=hppoc |
| 205 | + export DATABASE_PASSWD=pass12345 |
| 206 | + ``` |
| 207 | + **Important** repeat after every git pull (in some case you may need to apply permission to db/ directory, from blockchain-explorer/app/persistence/fabric/postgreSQL run: `chmod -R 775 db/` |
| 208 | + |
| 209 | +## Update configuration |
| 210 | + |
| 211 | +* Modify `app/platform/fabric/config.json` to define your fabric network connection profile: |
| 212 | + |
| 213 | + ```json |
| 214 | + { |
| 215 | + "network-configs": { |
| 216 | + "test-network": { |
| 217 | + "name": "Test Network", |
| 218 | + "profile": "./connection-profile/test-network.json", |
| 219 | + "enableAuthentication": false |
| 220 | + } |
| 221 | + }, |
| 222 | + "license": "Apache-2.0" |
| 223 | + } |
| 224 | + ``` |
| 225 | + |
| 226 | + * `test-network` is the name of your connection profile, and can be changed to any name |
| 227 | + * `name` is a name you want to give to your fabric network, you can change only value of the key `name` |
| 228 | + * `profile` is the location of your connection profile, you can change only value of the key `profile` |
| 229 | + |
| 230 | +* Modify connection profile in the JSON file `app/platform/fabric/connection-profile/test-network.json`: |
| 231 | + * Change `fabric-path` to your fabric network disk path in the test-network.json file: |
| 232 | + * Provide the full disk path to the adminPrivateKey config option, it ussually ends with `_sk`, for example: |
| 233 | + `/fabric-path/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk` |
| 234 | + * `adminUser` and `adminPassword` is the credential for user of Explorer to login the dashboard |
| 235 | + * `enableAuthentication` is a flag to enable authentication using a login page, setting to false will skip authentication. |
| 236 | + |
| 237 | +## Run create database script: |
| 238 | + |
| 239 | +* **Ubuntu** |
| 240 | + |
| 241 | + ``` |
| 242 | + $ cd blockchain-explorer/app/persistence/fabric/postgreSQL/db |
| 243 | + $ sudo -u postgres ./createdb.sh |
| 244 | + ``` |
| 245 | + |
| 246 | +* **MacOS** |
| 247 | + |
| 248 | + ``` |
| 249 | + $ cd blockchain-explorer/app/persistence/fabric/postgreSQL/db |
| 250 | + $ ./createdb.sh |
| 251 | + ``` |
| 252 | + |
| 253 | +Connect to the PostgreSQL database and run DB status commands: |
| 254 | + |
| 255 | +```shell |
| 256 | +$ sudo -u postgres psql -c '\l' |
| 257 | + List of databases |
| 258 | + Name | Owner | Encoding | Collate | Ctype | Access privileges |
| 259 | +----------------+----------+----------+---------+---------+----------------------- |
| 260 | + fabricexplorer | hppoc | UTF8 | C.UTF-8 | C.UTF-8 | |
| 261 | + postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 | |
| 262 | + template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres + |
| 263 | + | | | | | postgres=CTc/postgres |
| 264 | + template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres + |
| 265 | + | | | | | postgres=CTc/postgres |
| 266 | +(4 rows) |
| 267 | + |
| 268 | +$ sudo -u postgres psql fabricexplorer -c '\d' |
| 269 | + List of relations |
| 270 | + Schema | Name | Type | Owner |
| 271 | +--------+---------------------------+----------+------- |
| 272 | + public | blocks | table | hppoc |
| 273 | + public | blocks_id_seq | sequence | hppoc |
| 274 | + public | chaincodes | table | hppoc |
| 275 | + public | chaincodes_id_seq | sequence | hppoc |
| 276 | + public | channel | table | hppoc |
| 277 | + public | channel_id_seq | sequence | hppoc |
| 278 | + public | orderer | table | hppoc |
| 279 | + public | orderer_id_seq | sequence | hppoc |
| 280 | + public | peer | table | hppoc |
| 281 | + public | peer_id_seq | sequence | hppoc |
| 282 | + public | peer_ref_chaincode | table | hppoc |
| 283 | + public | peer_ref_chaincode_id_seq | sequence | hppoc |
| 284 | + public | peer_ref_channel | table | hppoc |
| 285 | + public | peer_ref_channel_id_seq | sequence | hppoc |
| 286 | + public | transactions | table | hppoc |
| 287 | + public | transactions_id_seq | sequence | hppoc |
| 288 | + public | write_lock | table | hppoc |
| 289 | + public | write_lock_write_lock_seq | sequence | hppoc |
| 290 | +(18 rows) |
| 291 | + |
| 292 | +``` |
| 293 | + |
| 294 | +## Build Hyperledger Explorer |
| 295 | + |
| 296 | +**Important:** repeat the below steps after every git pull |
| 297 | + |
| 298 | +* `./main.sh install` |
| 299 | + * To install, run tests, and build project |
| 300 | +- `./main.sh clean` |
| 301 | + * To clean the /node_modules, client/node_modules client/build, client/coverage, app/test/node_modules |
| 302 | + directories |
| 303 | + |
| 304 | +Or |
| 305 | + |
| 306 | +``` |
| 307 | +$ cd blockchain-explorer |
| 308 | +$ npm install |
| 309 | +$ cd client/ |
| 310 | +$ npm install |
| 311 | +$ npm run build |
| 312 | +``` |
| 313 | + |
| 314 | +## Run Hyperledger Explorer |
| 315 | + |
| 316 | +### Run Locally in Same Location |
| 317 | + |
| 318 | +* Modify `app/explorerconfig.json` to update sync settings. |
| 319 | + |
| 320 | + ```json |
| 321 | + "sync": { |
| 322 | + "type": "local" |
| 323 | + } |
| 324 | + ``` |
| 325 | + |
| 326 | +* `npm start` |
| 327 | + * It will have the backend and GUI service up |
| 328 | + |
| 329 | +* `npm run app-stop` |
| 330 | + * It will stop the node server |
| 331 | + |
| 332 | +**Note:** If Hyperledger Fabric network is deployed on other machine, please define the following environment variable |
| 333 | + |
| 334 | +``` |
| 335 | +$ DISCOVERY_AS_LOCALHOST=false npm start |
| 336 | +``` |
| 337 | +
|
| 338 | +### Run Standalone in Different Location |
| 339 | +
|
| 340 | +* Modify `app/explorerconfig.json` to update sync settings. |
| 341 | +
|
| 342 | + ```json |
| 343 | + "sync": { |
| 344 | + "type": "host" |
| 345 | + } |
| 346 | + ``` |
| 347 | +
|
| 348 | +* If the Hyperledger Explorer was used previously in your browser be sure to clear the cache before relaunching |
| 349 | +
|
| 350 | +* `./syncstart.sh` |
| 351 | + * It will have the sync node up |
| 352 | +
|
| 353 | +* `./syncstop.sh` |
| 354 | + * It will stop the sync node |
| 355 | +
|
| 356 | +**Note:** If Hyperledger Fabric network is deployed on other machine, please define the following environment variable |
| 357 | +
|
| 358 | +``` |
| 359 | +$ DISCOVERY_AS_LOCALHOST=false ./syncstart.sh |
| 360 | +``` |
| 361 | +
|
| 362 | +# Configuration |
| 363 | +
|
| 364 | +Please refer [README-CONFIG.md](README-CONFIG.md) for more detail of each configuration. |
| 365 | +
|
| 366 | +
|
| 367 | +# Logs |
| 368 | +
|
| 369 | +* Please visit the `./logs/console` folder to view the logs relating to console and `./logs/app` to view the application logs and visit the `./logs/db` to view the database logs. |
| 370 | +
|
| 371 | +# Troubleshooting |
| 372 | +
|
| 373 | +Please visit the [TROUBLESHOOT.md](TROUBLESHOOT.md) to view the Troubleshooting TechNotes for Hyperledger Explorer. |
| 374 | +
|
| 375 | +# License |
| 376 | +
|
| 377 | +Hyperledger Explorer Project source code is released under the Apache 2.0 license. The README.md, CONTRIBUTING.md files, and files in the "images", "__snapshots__" folders are licensed under the Creative Commons Attribution 4.0 International License. You may obtain a copy of the license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/. |
0 commit comments