A Proof-of-Concept blockchain network for managing civil registry certificates using Hyperledger Fabric. This repository includes the full infrastructure (Docker-based test network), chaincode, deployment scripts, and examples for interaction and testing.
Before starting, ensure you have:
- Docker (recommended: version 28.x or earlier due to networking changes)
- Docker Compose
- Fabric binaries installed (
peer,configtxgen, etc.) - Linux or WSL2 environment
The project uses a custom network.sh script to create and manage the Fabric test network.
# Create a new channel and join peers
./network.sh up createChannel -c certchannel -caThen, to restart it with the channel already created:
./network.sh down
./network.sh upThe chaincode deployment script packages, installs, approves, and commits a new chaincode version.
bash ./deployCC.sh certcc ../../chaincode 1.0 2 certchannelArguments:
- Chaincode name →
certcc - Chaincode path →
../../chaincode - Version →
1.1 - Sequence →
2 - Channel →
certchannel
You can create a temporary CLI container to interact with the peers manually.
Atention: The CLI container is already being created in the compose-test-net.yaml file as cli service, so you can also use it with docker exec -it cli bash.
docker run -it --rm \
--network fabric_test \
-v $(pwd)/organizations:/opt/organizations \
-v $(pwd)/deployCC.sh:/opt/deployCC.sh \
-e CORE_PEER_TLS_ENABLED=true \
-e CORE_PEER_LOCALMSPID=Org1MSP \
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 \
-e CORE_PEER_MSPCONFIGPATH=/opt/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp \
-e CORE_PEER_TLS_ROOTCERT_FILE=/opt/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt \
hyperledger/fabric-tools:2.5 bashBelow are examples of invoking and querying the chaincode.
peer chaincode invoke \
-o orderer.example.com:7050 \
-C certchannel \
--ordererTLSHostnameOverride orderer.example.com \
--tls --cafile $ORDERER_CA \
-n certcc \
--peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA \
--peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA \
-c '{"Args":["RegisterCert","CERT001","João Silva","2000-05-10","13:30","Hospital Municipal","Carlos Silva","Maria Silva","Cartorio A","Cartorio A","{\"docType\":\"birth\",\"notes\":\"registro inicial\"}"]}' \
--waitForEventpeer chaincode invoke \
-o orderer.example.com:7050 \
--ordererTLSHostnameOverride orderer.example.com \
--tls --cafile $ORDERER_CA \
-C certchannel -n certcc \
--peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA \
--peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA \
-c '{"Args":["UpdateCert","CERT001","name","João M. Silva"]}' \
--waitForEventpeer chaincode query -C certchannel -n certcc -c '{"Args":["VerifyCert","CERT001"]}'peer chaincode query \
-C certchannel \
-n certcc \
-c '{"Args":["GetHistory","CERT001"]}'List containers in a clean layout:
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"To run the Streamlit frontend for interacting with the blockchain network, follow these steps:
-
Navigate to the
frontenddirectory:cd frontend -
Install the required dependencies using pip:
pip install -r requirements.txt
-
Configure the .env file following the example in
.env.example. -
Start the Streamlit application:
streamlit run main.py
This project is published under the Apache 2 license.