Blockchain explorer Hyperledger explorer:
Blockchain explorer: official website https://github.com/hyperledger-labs/blockchain-explorer
You can see that he needs the following files:
- docker-compose.yaml
- test-network.json
- config.json
1. Docker container configuration file docker-compose-explorer.yaml
Note: If you have never set up postgreSQL, it is best to use the default account hppoc and password password, otherwise it will report the error role 'your own defined account' does not exist, which will cause the explorer container to hang in seconds after opening and cannot be accessed.
In the file, it is necessary to ensure that the ports and IPs correspond to each other, and the location of the files mounted in volumes must be correct.
version: '2.0'
volumes:
pgdata:
walletstore:
services:
explorerdb.mynetwork.com:
image: hyperledger/explorer-db:latest
container_name: explorerdb.mynetwork.com
hostname: explorerdb.mynetwork.com
ports:
- 5432:5432
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
explorer.mynetwork.com:
image: hyperledger/explorer:latest
container_name: explorer.mynetwork.com
hostname: explorer.mynetwork.com
ports:
- 9090:8080
extra_hosts:
- "explorerdb.mynetwork.com:192.168.235.129"
- "orderer0.example.com:192.168.235.129"
- "orderer1.example.com:192.168.235.129"
- "orderer2.example.com:192.168.235.129"
- "peer0.org1.example.com:192.168.235.129"
- "peer1.org1.example.com:192.168.235.129"
- "peer0.org2.example.com:192.168.235.129"
- "peer1.org2.example.com:192.168.235.129"
environment:
- DATABASE_HOST=explorerdb.mynetwork.com
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWD=password
- LOG_LEVEL_APP=debug
- LOG_LEVEL_DB=info
- LOG_LEVEL_CONSOLE=debug
- LOG_CONSOLE_STDOUT=true
- DISCOVERY_AS_LOCALHOST=false
volumes:
- ./config.json:/opt/explorer/app/platform/fabric/config.json
- ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
- ../crypto-config:/tmp/crypto
- walletstore:/opt/explorer/wallet
depends_on:
explorerdb.mynetwork.com:
condition: service_healthy
2. Write the network configuration file test-network.json
I named the network configuration file here: org1ProdNetworkConnection.json
Note: The id and password under adminCredential here are up to you, they don’t have to be the same as above, and the id and password here are used to access the browser later
{
"name": "prod-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "Org1",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"businesschannel": {
"peers": {
"peer0.org1.example.com": {
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true
},
"peer1.org1.example.com": {
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true
},
"peer0.org2.example.com": {
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true
},
"peer1.org2.example.com": {
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true
}
}
}
},
"organizations": {
"Org1": {
"mspid": "Org1MSP",
"peers": [
"peer0.org1.example.com",
"peer1.org1.example.com"
],
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk"
},
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
}
},
"Org2": {
"mspid": "Org2MSP",
"peers": [
"peer0.org2.example.com",
"peer1.org2.example.com"
],
"adminPrivateKey": {
"path": "/tmp/crypto/prod-network/peerOrganizations/org2.example.com/users/[email protected]/msp/keystore/priv_sk"
},
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp/signcerts/[email protected]"
}
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpcs://peer0.org1.example.com:7051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com",
"hostnameOverride": "peer0.org1.example.com",
"request-timeout": 120001
},
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
}
},
"peer1.org1.example.com": {
"url": "grpcs://peer1.org1.example.com:8051",
"grpcOptions": {
"ssl-target-name-override": "peer1.org1.example.com",
"hostnameOverride": "peer1.org1.example.com",
"request-timeout": 120001
},
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
}
},
"peer0.org2.example.com": {
"url": "grpcs://peer0.org2.example.com:9051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org2.example.com",
"hostnameOverride": "peer0.org2.example.com",
"request-timeout": 120001
},
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
}
},
"peer1.org2.example.com": {
"url": "grpcs://peer1.org2.example.com:10051",
"grpcOptions": {
"ssl-target-name-override": "peer1.org2.example.com",
"hostnameOverride": "peer1.org2.example.com",
"request-timeout": 120001
},
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt"
}
}
}
}
3. Write the configuration file config.tx
{
"network-configs": {
"prod-network": {
"name": "Prod Network",
"profile": "./connection-profile/org1ProdNetworkConnection.json"
}
},
"license": "Apache-2.0"
}
4. File directory
After the files are ready, they must be placed in a directory, and the format of the directory must be as follows:
./
├── config.json
├── connection-profile
│ └── org1ProdNetworkConnection.json
└── docker-compose-explorer.yaml
5. Start the container
Start Hyperledger Explorer:
docker-compose -f docker-compose-explorer.yaml up -d
Cleanup (does not remove persistent data):
docker-compose -f docker-compose-explorer.yaml down
Clean up completely:
docker-compose -f docker-compose-explorer.yaml down -v
Access after startup http://localhost:9090/
:
Username and password here: use the password in org1ProdNetworkConnection.json to log in.