# .env File Lines 3-4 Reference

**Date**: 2025-12-24  
**Purpose**: Reference for what should be on lines 3-4 of the .env file

---

## Typical .env File Structure

Based on the project structure, a typical `.env` file should look like:

```bash
# Chain 138 RPC Configuration
RPC_URL_138=http://192.168.11.250:8545
RPC_URL=http://192.168.11.250:8545
PRIVATE_KEY=<your_private_key_here>
```

**Lines 3-4 would typically be**:
- **Line 3**: `RPC_URL=http://192.168.11.250:8545`
- **Line 4**: `PRIVATE_KEY=<your_private_key_here>`

---

## Expected Content for Lines 3-4

### Line 3: RPC_URL
```bash
RPC_URL=http://192.168.11.250:8545
```

**Purpose**: Sets the RPC endpoint for ChainID 138  
**Format**: `RPC_URL=<http_or_https_url>`  
**Default**: `http://192.168.11.250:8545`

### Line 4: PRIVATE_KEY
```bash
PRIVATE_KEY=<your_64_character_hex_private_key>
```

**Purpose**: Deployer private key for contract deployments  
**Format**: 
- Without 0x prefix: `1234567890abcdef...` (64 hex characters)
- With 0x prefix: `0x1234567890abcdef...` (66 characters total)

**Example**:
```bash
PRIVATE_KEY=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
```

---

## Verification Commands

### Check Line 3 (RPC_URL)
```bash
cd /home/intlc/projects/proxmox/smom-dbis-138
sed -n '3p' .env
# Should output: RPC_URL=http://192.168.11.250:8545
```

### Check Line 4 (PRIVATE_KEY)
```bash
cd /home/intlc/projects/proxmox/smom-dbis-138
sed -n '4p' .env | sed 's/PRIVATE_KEY=\(.\{10\}\).*/PRIVATE_KEY=\1...***HIDDEN***/'
# Should show: PRIVATE_KEY=<first_10_chars>...***HIDDEN***
```

### Verify Both Lines
```bash
cd /home/intlc/projects/proxmox/smom-dbis-138
echo "Line 3:"
sed -n '3p' .env
echo ""
echo "Line 4 (hidden):"
sed -n '4p' .env | sed 's/\(.\{15\}\).*/\1...***HIDDEN***/'
```

---

## Common Issues

### Issue 1: PRIVATE_KEY Missing or Empty
**Symptom**: Deployment fails with "PRIVATE_KEY not found"

**Fix**:
```bash
# Check if line 4 has PRIVATE_KEY
sed -n '4p' .env | grep -q "^PRIVATE_KEY=" && echo "✅ Set" || echo "❌ Missing"

# If missing, add it:
echo "PRIVATE_KEY=<your_key>" >> .env
```

### Issue 2: Invalid PRIVATE_KEY Format
**Symptom**: "Invalid PRIVATE_KEY format" error

**Fix**:
```bash
# Verify format (should be 64 hex chars, with or without 0x)
PRIVATE_KEY=$(sed -n '4p' .env | cut -d'=' -f2)
if [[ "$PRIVATE_KEY" =~ ^0x[0-9a-fA-F]{64}$ ]] || [[ "$PRIVATE_KEY" =~ ^[0-9a-fA-F]{64}$ ]]; then
    echo "✅ Valid format"
else
    echo "❌ Invalid format - should be 64 hex characters"
fi
```

### Issue 3: RPC_URL Incorrect
**Symptom**: Cannot connect to RPC

**Fix**:
```bash
# Check line 3
RPC_URL=$(sed -n '3p' .env | cut -d'=' -f2)
echo "RPC_URL: $RPC_URL"

# Test connection
cast block-number --rpc-url "$RPC_URL" || echo "❌ Cannot connect"
```

---

## Quick Check Script

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

echo "Checking .env lines 3-4..."
echo ""

# Line 3: RPC_URL
echo "Line 3 (RPC_URL):"
LINE3=$(sed -n '3p' .env)
if [[ "$LINE3" =~ ^RPC_URL= ]]; then
    echo "✅ $LINE3"
else
    echo "❌ Expected: RPC_URL=http://192.168.11.250:8545"
    echo "   Found: $LINE3"
fi
echo ""

# Line 4: PRIVATE_KEY
echo "Line 4 (PRIVATE_KEY):"
LINE4=$(sed -n '4p' .env)
if [[ "$LINE4" =~ ^PRIVATE_KEY= ]]; then
    KEY_VALUE=$(echo "$LINE4" | cut -d'=' -f2-)
    if [ -z "${KEY_VALUE// }" ]; then
        echo "❌ PRIVATE_KEY is set but empty"
    else
        KEY_PREFIX=$(echo "$KEY_VALUE" | cut -c1-10)
        KEY_LENGTH=${#KEY_VALUE}
        echo "✅ PRIVATE_KEY is set (prefix: ${KEY_PREFIX}..., length: $KEY_LENGTH)"
        
        # Validate format
        if [[ "$KEY_VALUE" =~ ^0x[0-9a-fA-F]{64}$ ]] || [[ "$KEY_VALUE" =~ ^[0-9a-fA-F]{64}$ ]]; then
            echo "   ✅ Format is valid"
        else
            echo "   ⚠️  Format may be invalid (expected 64 hex chars)"
        fi
    fi
else
    echo "❌ PRIVATE_KEY not found on line 4"
    echo "   Found: $LINE4"
fi
```

---

## Update Lines 3-4

If you need to update these lines:

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

# Update line 3 (RPC_URL)
sed -i '3s|.*|RPC_URL=http://192.168.11.250:8545|' .env

# Update line 4 (PRIVATE_KEY) - REPLACE <your_key> with actual key
sed -i '4s|.*|PRIVATE_KEY=<your_private_key>|' .env

# Verify changes
echo "Updated lines 3-4:"
sed -n '3,4p' .env
```

---

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

