Hyperledger Explorer is a simple, powerful, easy-to-use, highly maintainable open-source blockchain explorer for viewing activity on the underlying blockchain network.
Software Installation
Install Node
Download the tarball
unzip
tar -xvf node-v12.16.2-linux-x64.tar.xz
mv node-v12.16.2-linux-x64 node-v12.16.2
Configure global use
ln -s /usr/local/node-v12.16.2/bin/node /usr/local/bin/node
ln -s /usr/local/node-v12.16.2/bin/npm /usr/local/bin/npm
Install PostgreSQL
apt-get install postgresql
start service
/etc/init.d/postgresql start
Modify user password:
su - postgres switch user, the prompt will change to '-bash-4.2$' after execution
psql -U postgres Log in to the database, after execution the prompt changes to 'postgres=#'
ALTER USER postgres WITH PASSWORD 'postgres'; Set the postgres user password to postgres
\q exit database
exit Exit the command line interface
uninstall
apt-get --purge remove postgresql*
apt-get --purge remove postgis*
install jq
apt install jq
install gcc
apt install gcc
gcc --version
Hyperledger Explorer Download
cd /opt/gopath/src/github.com/hyperledger
git clone https://github.com/hyperledger/blockchain-explorer.git
create database
We use the default version for database creation:
cd blockchain-explorer/app
vi explorerconfig.json
Modify the configuration as follows:
{
"persistence": "postgreSQL",
"platforms": ["fabric"],
"postgreSQL": {
"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer",
"username": "postgres",
"passwd": "postgres"
},
"sync": {
"type": "local",
"platform": "fabric",
"blocksSyncTime": "1"
},
"jwt": {
"secret": "a secret phrase!!",
"expiresIn": "2h"
}
}
Run the script that creates the database
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh
View database status command:
sudo -u postgres psql -c '\l'
sudo -u postgres psql fabricexplorer -c '\d'
Define fabric network connection parameters
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric/
vim config.json
Set enableAuthentication attribute false to turn off login authentication
{
"network-configs": {
"first-network": {
"name": "firstnetwork",
"profile": "./connection-profile/first-network.json",
"enableAuthentication": false
}
},
"license": "Apache-2.0"
}
Set first-network.json configuration
Continue to set up (the Fabric network environment must be in a normal startup state, otherwise the file in the following path does not exist)
cd /opt/gopath/src/github.com/hyperledger/blockchainexplorer/app/platform/fabric/connection-profile/
vim first-network.json
The key settings are as follows:
{
"name": "first-network",
"version": "1.0.0",
"license": "Apache-2.0",
"client": {
"tlsEnable": true,
"caCredential": {
"id": "admin",
"password": "adminpw"
},
"adminCredential": {
"id": "admin",
"password": "123456",
"affiliation": "org1.department1"
},
"enableAuthentication": true,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"zmeduchannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"adminPrivateKey": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/9ccc1d5b3baae6d7a0aa697d6cae8009ad55c12cbdba34cdaeaaf7ab15d96ab0_sk"
},
"peers": ["peer0.org1.example.com"],
"signedCert": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org1.example.com:7051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
}
},
"certificateAuthorities": {
"ca0": {
"url": "https://peer0.org1.example.com:7054",
"httpOptions": {
"verify": false
},
"tlsCACerts": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"
},
"caName": "ca0"
}
}
}
- adminCredential Set the user password for browser login
- channels set channel name, peer0 name
- organizations Set the certification path
- peers set peer-ca certificate path
- certificateAuthorities set ca certificate path
Note: It needs to be explained that these two "tlsCACerts" are not in the same dictionary, special attention should be paid when configuring, and the file path of your own is the main one.
compile
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
npm install --unsafe-perm
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/client
npm install --unsafe-perm
npm run build --unsafe-perm
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
npm run build --unsafe-perm
start up
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
./start.sh
background start
nohup ./start.sh logs/log.log 2>&1 &
View logs blockchain-explorer/logs/console/
stop
./stop.sh
access
http://127.0.0.1:8080/