VeriChain is a blockchain-based pharmaceutical supply chain tracking system using Hyperledger Fabric, Node.js, and React.
- OS: Linux (Ubuntu/WSL2 recommended) or macOS
- Docker: v20.10+ (with Docker Compose v2.x or v1.29+)
- Node.js: v16.x or v18.x (v20+ might have OpenSSL issues with older Fabric SDKs)
- Hyperledger Fabric Binaries: v2.5.x (installed in
./bin)
The network consists of 4 Organizations (Pharma1, Pharma2, Distributor, Retailer) and 1 Orderer.
-
Navigate to the project root:
cd verichain -
Start the Network: This script will bring down any existing network, generate crypto material, create the channel
verichain-channel, and deploy the chaincode../setup_verichain.sh
Note: This might take a few minutes.
-
Verify Chaincode Deployment: Ensure the chaincode
basicis deployed toverichain-channel.export PATH=$PWD/bin:$PATH peer lifecycle chaincode querycommitted --channelID verichain-channel --name basic
VeriChain uses PostgreSQL for off-chain data (inventory, ZK proofs) and caching.
-
Start PostgreSQL:
docker-compose up -d postgres
Port: 5433 (mapped to container 5432) User: verichain Password: verichain_secret Database: verichain
-
Verify Schema: The database initializes with
verichain-api/src/db/schema.sql.
The Node.js API interacts with the Fabric network and PostgreSQL.
-
Navigate to API directory:
cd verichain-api -
Install Dependencies:
npm install
-
Restore Identities (Important for Fresh Network): If you restarted the network, you must import the new admin/user certificates into the wallet.
node restore_identities.js
-
Start the Server:
npm start
The React frontend provides the user interface.
-
Navigate to Frontend directory:
cd verichain-frontend -
Install Dependencies:
npm install
-
Start the Development Server:
npm run dev
-
Login:
- Pharma: Use the "Pharma 1" demo button.
- Distributor: Use the "Distributor" demo button.
- Retailer: Use the "Retailer" demo button.
-
Create Asset (Pharma):
- Go to "Create Asset".
- Enter details (e.g., ID:
VAX-001, Drug:Covid-19 Vaccine). - Click "Create Asset".
-
Simulate Transit (Pharma/Distributor):
- Go to "Dashboard".
- Click "Simulate Transit" on the asset.
- This generates a ZK Proof (mocked/simulated) and transfers ownership to Distributor.
-
Accept Shipment (Retailer):
- Login as Retailer.
- Go to "Inventory".
- Click "Accept Shipment" for pending assets.
- This transfers ownership to Retailer and updates status to
STOCKED.
-
Query Ledger:
- Use the script to see the full history of an asset:
./query_ledger.sh VAX-001
VeriChain includes a bridge to notarize ZK-proofs on the Shardeum Testnet.
-
Deploy Contract:
- Open Remix IDE.
- Create a new file
Notary.soland paste the content fromshardeum/Notary.sol. - Compile and Deploy to Shardeum Sphinx 1.X (Injected Provider - MetaMask).
- Copy the Deployed Contract Address.
-
Configure API:
- Open
verichain-api/.env. - Add your Private Key (with test SHM) and the Contract Address:
SHARDEUM_PRIVATE_KEY=your_private_key_here SHARDEUM_CONTRACT_ADDRESS=0x...
- Restart the API:
npm start.
- Open
- When you generate a ZK Proof (as Distributor), click the "Notarize to Shardeum" button (if implemented in UI) or call the API endpoint:
POST /api/transit/notarizewith{ "assetId": "...", "proofHash": "..." }. - The system will return a Transaction Hash and a QR Code URL pointing to the Shardeum Explorer.
-
"Peer endorsements do not match":
- This usually means the chaincode is non-deterministic. We fixed this by using transaction timestamps. Redeploy chaincode if this recurs.
-
"Connect ECONNREFUSED 127.0.0.1:5433":
- PostgreSQL is not running. Run
docker-compose up -d postgres.
- PostgreSQL is not running. Run
-
"User not found in wallet":
- Run
node restore_identities.jsinverichain-apito restore demo users.
- Run
-
"Collection not found":
- Chaincode was deployed without
collections_config.json. Redeploy with the-cccgflag.
- Chaincode was deployed without