The blogger has also learned a lot of bloggers’ construction process in the process of building the Hyperledger Fabric blockchain browser recently, stepped on a lot of thunder, stepped on a lot
Pit, now I will share the detailed process of the successfully built Hyperledger Fabric blockchain browser as follows, to help everyone avoid lightning and close the pit
fabric browser
Hyperledger Explorer is a simple, powerful, easy-to-use, well-maintained open-source utility for browsing live
move. Users can configure and build Hyperledger Explorer on MacOS and Ubuntu. You must first ensure that your previous project has successfully started.
Prerequisites for building a Hyperledger Fabric blockchain browser
1. Successfully built and deployed Hyperledger Fabric 2.4 (2.x) network
Build directory structure
Create a new sibling directory explorer under the hyperledger directory
Then enter the test-network directory to start the network
and start the Fabric network
./network.sh up createChannel -ca -s couchdb
Copy the certificate folder organizations generated after successfully starting the network to the previously created explorer folder
Then download the following three configuration files (official recommendation) but it is difficult to download due to network reasons
docker-compose.yaml
config.json
test-network.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml
Therefore, it is recommended that you download the official blockchain project first, and then put the three required configuration files into the explorer folder
Official blockchain explorer project address https://github.com/hyperledger-labs/blockchain-explorer
Here you need to put the test-network.json file in the connection-profile directory, and the others are in the same level directory in the explorer directory
So far, the complete directory structure required to start the blockchain browser is as follows:
docker-compose.yaml
config.json
connection-profile/test-network.json
organizations/ordererOrganizations/
organizations/peerOrganizations/
The directory structure diagram in the virtual machine is as follows:
Modify three configuration files
find the docker network
docker network ls
We can see that the docker network of this blockchain browser is fabric_test, which needs to be modified later when modifying the configuration file
config.json
{
"network-configs": {
"test-network": {
"name": "fabric_test",
"profile": "./connection-profile/test-network.json"
}
},
"license": "Apache-2.0"
}
test-network.json
{
"name": "fabric_test",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "hhhh",
"password": "123456"
},
"enableAuthentication": true,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk"
},
"peers": ["peer0.org1.example.com"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org1.example.com:7051"
}
}
}
docker-compose.yaml
# SPDX-License-Identifier: Apache-2.0
version: '2.1'
volumes:
pgdata:
walletstore:
networks:
mynetwork.com:
name: fabric_test
services:
explorerdb.mynetwork.com:
image: hyperledger/explorer-db:latest
container_name: explorerdb.mynetwork.com
hostname: explorerdb.mynetwork.com
environment:
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWORD=password
healthcheck:
test: "pg_isready -h localhost -p 5432 -q -U postgres"
interval: 30s
timeout: 10s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- mynetwork.com
explorer.mynetwork.com:
image: hyperledger/explorer:latest
container_name: explorer.mynetwork.com
hostname: explorer.mynetwork.com
environment:
- DATABASE_HOST=explorerdb.mynetwork.com
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWD=password
- LOG_LEVEL_APP=info
- LOG_LEVEL_DB=info
- LOG_LEVEL_CONSOLE=debug
- LOG_CONSOLE_STDOUT=true
- DISCOVERY_AS_LOCALHOST=false
- PORT=${
PORT:-8080}
volumes:
- ${
EXPLORER_CONFIG_FILE_PATH}:/opt/explorer/app/platform/fabric/config.json
- ${
EXPLORER_PROFILE_DIR_PATH}:/opt/explorer/app/platform/fabric/connection-profile
- ${
FABRIC_CRYPTO_PATH}:/tmp/crypto
- walletstore:/opt/explorer/wallet
ports:
- ${
PORT:-8080}:${
PORT:-8080}
depends_on:
explorerdb.mynetwork.com:
condition: service_healthy
networks:
- mynetwork.com
start browser
Execute the following commands in sequence
If it was started before, disable mirroring first
sudo docker-compose down
Two named volumes are allocated in docker-compose.yaml for persistent data (Postgres data and user wallet). If you want to clear these named volumes
sudo docker-compose down -v
Be sure to set the following three environment variables, otherwise an error will be reported when you start the browser! ! ! ! ! ! !
export EXPLORER_CONFIG_FILE_PATH=./config.json
export EXPLORER_PROFILE_DIR_PATH=./connection-profile
export FABRIC_CRYPTO_PATH=./organizations
Finally start the blockchain explorer
sudo docker-compose up -d
open browser input
http://127.0.0.1:8080
Successfully launched the browser
The default login name and password are as follows
"id": exploreradmin
"password": exploreradminpw
You can also modify the login name and password in the test-network.json file
"adminCredential": {
},
The following interface appears to indicate that the startup is successful.
After logging in, you can see the detailed information of the fabric browser: block information, channel information, node information, etc.