# Manual PRIVATE_KEY Setup Instructions

**Date**: 2025-12-24  
**Status**: Ready for manual setup

---

## PRIVATE_KEY to Set

```
PRIVATE_KEY=0x5373d11ee2cad4ed82b9208526a8c358839cbfe325919fb250f062a25153d1c8
```

---

## Step 1: Create/Update .env File

Open a terminal and run:

```bash
cd /home/intlc/projects/proxmox/smom-dbis-138

# Create or update .env file
cat > .env << 'EOF'
# Chain 138 RPC Configuration
RPC_URL_138=http://192.168.11.250:8545
RPC_URL=http://192.168.11.250:8545
PRIVATE_KEY=0x5373d11ee2cad4ed82b9208526a8c358839cbfe325919fb250f062a25153d1c8
EOF

# Set secure permissions
chmod 600 .env
```

---

## Step 2: Verify PRIVATE_KEY

```bash
cd /home/intlc/projects/proxmox/smom-dbis-138

# Check if PRIVATE_KEY is set
grep "^PRIVATE_KEY=" .env

# Verify deployer address
export PRIVATE_KEY=0x5373d11ee2cad4ed82b9208526a8c358839cbfe325919fb250f062a25153d1c8
cast wallet address $PRIVATE_KEY
```

**Expected output**: A deployer address (0x...)

---

## Step 3: Check Deployer Balance

```bash
cd /home/intlc/projects/proxmox/smom-dbis-138

# Load .env
source .env

# Get deployer address
DEPLOYER=$(cast wallet address $PRIVATE_KEY)

# Check balance
cast balance $DEPLOYER --rpc-url $RPC_URL
```

**Recommended**: At least 0.1 ETH for deployments

---

## Step 4: Run Deployment

Once PRIVATE_KEY is set and verified:

```bash
cd /home/intlc/projects/proxmox/smom-dbis-138

# Load environment
source .env

# Run complete deployment and integration
./scripts/deploy-and-integrate-all.sh
```

---

## Alternative: Use the Setup Script

If the script works in your environment:

```bash
cd /home/intlc/projects/proxmox/smom-dbis-138
bash scripts/set-private-key.sh
```

This script will:
- Create/update .env file
- Set PRIVATE_KEY
- Set secure permissions
- Verify the key
- Show deployer address and balance

---

## Troubleshooting

### Issue: "PRIVATE_KEY not found"

**Solution**: Make sure .env file exists and contains PRIVATE_KEY:
```bash
cd /home/intlc/projects/proxmox/smom-dbis-138
cat .env | grep PRIVATE_KEY
```

### Issue: "Invalid PRIVATE_KEY format"

**Solution**: Verify the key is 64 hex characters (with or without 0x prefix):
```bash
# Should be 66 characters with 0x, or 64 without
echo "0x5373d11ee2cad4ed82b9208526a8c358839cbfe325919fb250f062a25153d1c8" | wc -c
# Should output: 67 (including newline) or 66
```

### Issue: "Cannot connect to RPC"

**Solution**: Verify RPC URL is correct:
```bash
cast block-number --rpc-url http://192.168.11.250:8545
```

---

## Quick Verification Checklist

- [ ] .env file exists at `/home/intlc/projects/proxmox/smom-dbis-138/.env`
- [ ] PRIVATE_KEY is set in .env
- [ ] File permissions are 600 (secure)
- [ ] PRIVATE_KEY format is valid (64 hex chars)
- [ ] Deployer address can be derived from PRIVATE_KEY
- [ ] Deployer has sufficient balance (0.1+ ETH recommended)

---

## Next Steps After Setup

1. ✅ PRIVATE_KEY configured
2. ⏳ Run deployment: `./scripts/deploy-and-integrate-all.sh`
3. ⏳ Verify deployments: `./scripts/verify-deployments.sh`
4. ⏳ Test contracts: `./scripts/test-contracts.sh`

---

**Last Updated**: 2025-12-24

