A Hyperledger Fabric blockchain network for managing Zakat transactions between YDSF Malang and YDSF Jatim organizations.
This project implements a blockchain network for managing and tracking Zakat transactions. It enables transparent recording of Zakat collection and distribution between multiple organizations.
This is a release candidate (RC) version where:
- Chaincode implementation is feature-complete and tested
- Basic network setup scripts are provided
- Network scripts are for development/testing only
- Production deployment requires additional security hardening
- Install prerequisites
- Clone the repository
- Install Fabric:
./install-fabric.sh
- Run the development demo:
./scripts/demo/demo.sh
Note: These scripts are for development and testing purposes. For production deployment, follow Hyperledger Fabric's official guidelines.
- Go 1.20+
- Docker and Docker Compose
- Hyperledger Fabric 2.4.0
- OpenSSL
- Git
- YDSF Malang (
ydsfmalang.example.local
) - YDSF Jatim (
ydsfjatim.example.local
) - Orderer Org (
orderer.example.local
)
- 1 Orderer node (etcdraft)
- 2 Peer nodes (one per organization)
- 1 Channel (
zakat-channel
) - LevelDB state database
- Zakat chaincode
The default Docker network is fabric_test
. This network connects all Hyperledger Fabric components, including peers, orderers, and instances.
fabric-zakat/
├── bin/ # Fabric binaries
├── chaincode/
│ └── zakat/ # Zakat chaincode implementation
├── config/
│ ├── dev/ # Development environment configs
│ │ ├── configtx.yaml
│ │ └── crypto-config.yaml
│ ├── prod/ # Production environment configs
│ └── docker-compose-test.yaml
├── scripts/
│ ├── demo/ # Demo and testing scripts
│ │ ├── env.sh # Environment variables
│ │ ├── 00_cleanup.sh
│ │ ├── 01_network_setup.sh
│ │ ├── 02_channel_setup.sh
│ │ ├── 03_chaincode_setup.sh
│ │ └── 04_test_chaincode.sh
│ └── temp/ # Temporary files directory
├── generate.sh # Network material generation script
└── install-fabric.sh # Fabric installation script
The Zakat chaincode provides a robust implementation for managing Zakat transactions on the Hyperledger Fabric network. It supports the following operations:
- Initialize Ledger: Bootstrap the ledger with initial Zakat data
- Add Zakat: Record new Zakat transactions with comprehensive validation
- Query Zakat: Retrieve specific Zakat transaction details
- Get All Zakat: List all recorded Zakat transactions
- Distribute Zakat: Track Zakat distribution to beneficiaries
- Validate Transactions: Comprehensive validation for all operations
type Zakat struct {
ID string `json:"ID"` // Format: ZKT-ORG-YYYYMM-NNNN
Muzakki string `json:"muzakki"` // Zakat payer
Amount float64 `json:"amount"` // Zakat amount
Type string `json:"type"` // maal/fitrah
Status string `json:"status"` // collected/distributed
Organization string `json:"organization"` // YDSF Malang/YDSF Jatim
Timestamp string `json:"timestamp"` // ISO 8601 format
Mustahik string `json:"mustahik"` // Zakat recipient
Distribution float64 `json:"distribution"` // Distributed amount
DistributedAt string `json:"distributedAt"`// Distribution timestamp
}
- Zakat ID: Must follow format
ZKT-ORG-YYYYMM-NNNN
- Amount: Must be positive
- Type: Must be either 'maal' or 'fitrah'
- Organization: Must be either 'YDSF Malang' or 'YDSF Jatim'
- Timestamps: Must be in ISO 8601 format
- Status: Automatically managed (collected → distributed)
The chaincode includes comprehensive test coverage:
- Unit tests for all functions
- Error scenario testing
- Mock-based testing
- Table-driven tests
To run tests:
cd chaincode/zakat
go test -v
-
Install Prerequisites: Ensure you have the following installed:
- Go 1.20+
- Docker and Docker Compose
- OpenSSL
- Git
-
Source environment variables: The
env.sh
script contains the necessary environment variables for development:cd scripts/demo source env.sh
-
Generate network materials:
cd $PROJECT_ROOT ./generate.sh
-
Start development network:
cd scripts/demo ./01_network_setup.sh
-
Run the test suite:
cd chaincode/zakat go test -v
-
Run the development network:
cd scripts/demo ./demo.sh
For production deployment:
- Follow Hyperledger Fabric's official guidelines for production networks
- Implement proper security measures:
- Configure TLS certificates
- Set up proper access control
- Enable security features
- Configure proper endorsement policies
- Perform security audits
- Set up monitoring and backup procedures
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- YDSF Malang
- YDSF Jatim
- Hyperledger Fabric Community
- Complete Zakat management functionality
- Comprehensive validation and error handling
- Full test coverage
- Development and testing tools provided
- YDSF Malang
- YDSF Jatim
- Hyperledger Fabric 2.4.0+
- Go 1.20+
- Docker and Docker Compose
- Initial release candidate
- Chaincode implementation complete
- Development scripts provided
- Pending production validation
- Input validation for all parameters
- Status transitions are strictly controlled
- Organization validation enforced
- Transaction integrity checks
- Production hardening required
- Path Resolution
- Ensure PROJECT_ROOT is set correctly
- Use absolute paths in Docker volumes
- Docker Issues
- Run cleanup script
- Check Docker daemon
- Verify network connectivity
- Chaincode Issues
- Check Go environment
- Verify dependencies
- Check package IDs
- Check logs:
docker logs peer0.ydsfmalang.example.local
docker logs orderer.example.local
- Verify network status:
docker ps
docker network ls
- Network Security
- Enable TLS
- Configure firewalls
- Use proper certificates
- Access Control
- Set proper MSP policies
- Configure endorsement policies
- Regular access audits
- Data Privacy
- Use private data collections
- Implement proper ACLs
- Regular security audits