# Hyperledger Services Deployment Guide

Complete deployment guide for Hyperledger services (Firefly, Cacti, Fabric, Indy) on Proxmox VE.

## 📋 Overview

This document covers deployment of additional Hyperledger blockchain frameworks beyond Besu:
- **Firefly**: Web3 gateway for enterprise applications
- **Cacti**: Blockchain integration platform
- **Fabric**: Permissioned blockchain framework
- **Indy**: Self-sovereign identity ledger

## 🚀 Quick Deployment

### Deploy All Hyperledger Services

```bash
cd /opt/smom-dbis-138-proxmox
./scripts/deployment/deploy-hyperledger-services.sh
```

### Deploy Individual Services

```bash
# Deploy only Firefly
DEPLOY_FIREFLY=true DEPLOY_CACTI=false DEPLOY_FABRIC=false DEPLOY_INDY=false \
  ./scripts/deployment/deploy-hyperledger-services.sh

# Deploy only Cacti
DEPLOY_FIREFLY=false DEPLOY_CACTI=true DEPLOY_FABRIC=false DEPLOY_INDY=false \
  ./scripts/deployment/deploy-hyperledger-services.sh
```

## 🔧 Service Details

### Hyperledger Firefly

**VMID Range**: 150-159  
**Default VMID**: 150  
**Container**: `firefly-1`

**After deployment**:
1. Configure Besu connection:
```bash
pct exec 150 -- bash -c "cd /opt/firefly && \
  sed -i 's|FF_BLOCKCHAIN_RPC=.*|FF_BLOCKCHAIN_RPC=http://192.168.11.250:8545|' docker-compose.yml && \
  sed -i 's|FF_BLOCKCHAIN_WS=.*|FF_BLOCKCHAIN_WS=ws://192.168.11.250:8546|' docker-compose.yml"
```

2. Start service:
```bash
pct exec 150 -- systemctl start firefly
```

3. Access API:
```bash
curl http://10.3.1.60:5000/api/v1/status
```

---

### Hyperledger Cacti

**VMID Range**: 150-159  
**Default VMID**: 151  
**Container**: `cacti-1`

**After deployment**:
1. Configure Besu connection:
```bash
pct exec 151 -- bash -c "cd /opt/cacti && \
  sed -i 's|BESU_RPC_URL=.*|BESU_RPC_URL=http://192.168.11.250:8545|' docker-compose.yml && \
  sed -i 's|BESU_WS_URL=.*|BESU_WS_URL=ws://192.168.11.250:8546|' docker-compose.yml"
```

2. Start service:
```bash
pct exec 151 -- systemctl start cacti
```

3. Access API:
```bash
curl http://10.3.1.61:4000/api/v1/api-server/healthcheck
```

---

### Hyperledger Fabric

**VMID Range**: 150-159  
**Default VMID**: 152  
**Container**: `fabric-1`

**After deployment**:
1. Generate crypto materials (customize for your network):
```bash
pct exec 152 -- bash
cd /opt/fabric
# Generate crypto materials
cryptogen generate --config=./config/crypto-config.yaml
# Generate genesis block
configtxgen -profile TestNetwork -channelID test-channel -outputBlock ./network/genesis.block
```

2. Configure network in `docker-compose.yml` (requires manual setup)

3. Start Fabric network

---

### Hyperledger Indy

**VMID Range**: 150-159  
**Default VMID**: 153  
**Container**: `indy-1`

**After deployment**:
1. Generate genesis transactions:
```bash
pct exec 153 -- bash
cd /opt/indy
# Generate pool transactions (requires pool configuration)
# See Indy documentation for pool setup
```

2. Configure pool name:
```bash
pct exec 153 -- bash -c "cd /opt/indy && \
  sed -i 's|NETWORK_NAME=.*|NETWORK_NAME=smom-dbis-138|' docker-compose.yml"
```

3. Start service:
```bash
pct exec 153 -- systemctl start indy
```

## 🔗 Integration

### Firefly with Besu
- Firefly connects to Besu RPC nodes
- Uses Besu for transaction submission
- Monitors Besu events
- Supports tokenization on Besu chain

### Cacti with Besu
- Cacti Besu connector connects to Besu network
- Enables cross-chain operations
- Can bridge assets between Besu and other chains

### Fabric Integration
- Can use Fabric Gateway API
- Connect via REST/GRPC
- Separate permissioned network

### Indy Integration
- Independent identity ledger
- Can issue credentials for Besu addresses
- Supports decentralized identity verification

## 📊 Resource Summary

| Service | CPU | RAM | Disk | VMID |
|---------|-----|-----|------|------|
| Firefly | 2 | 4GB | 50GB | 150 |
| Cacti | 2 | 4GB | 50GB | 151 |
| Fabric | 4 | 8GB | 100GB | 152 |
| Indy | 4 | 8GB | 100GB | 153 |

**Total Additional Resources**: ~12 cores, 24GB RAM, 300GB disk

## 🆘 Troubleshooting

### Firefly Issues
```bash
# Check logs
pct exec 150 -- journalctl -u firefly -f

# Check Docker containers
pct exec 150 -- docker ps
pct exec 150 -- docker-compose -f /opt/firefly/docker-compose.yml logs
```

### Cacti Issues
```bash
# Check logs
pct exec 151 -- journalctl -u cacti -f
pct exec 151 -- docker-compose -f /opt/cacti/docker-compose.yml logs
```

### Fabric Issues
```bash
# Check Docker containers
pct exec 152 -- docker ps
# Review network logs
pct exec 152 -- docker logs <container-name>
```

### Indy Issues
```bash
# Check all node logs
pct exec 153 -- docker-compose -f /opt/indy/docker-compose.yml logs
# Check individual node
pct exec 153 -- docker logs indy-node-1
```

## 📚 Additional Resources

- [Firefly Documentation](https://hyperledger.github.io/firefly/)
- [Cacti Documentation](https://github.com/hyperledger/cacti)
- [Fabric Documentation](https://hyperledger-fabric.readthedocs.io/)
- [Indy Documentation](https://hyperledger-indy.readthedocs.io/)

