# thirdweb Bridge Environment Variables Needed

**Date**: 2025-01-27  
**Purpose**: Document required thirdweb Bridge API secrets for .env files

---

## Missing Environment Variables

### Current Status: ❌ **NOT CONFIGURED**

**Checked Files**:
- `smom-dbis-138/.env` - No thirdweb variables found
- `smom-dbis-138/.env.example` - No thirdweb variables found
- `smom-dbis-138/terraform/phases/phase1/config/env.chain138.template` - No thirdweb variables found
- `smom-dbis-138/terraform/phases/phase1/config/env.mainnet.template` - No thirdweb variables found

---

## Required Environment Variables

### 1. thirdweb Bridge API Secret Key 🔴 **CRITICAL**

**Variable Name**: `THIRDWEB_SECRET_KEY`

**Description**: Secret key for thirdweb Bridge API authentication

**How to Obtain**:
1. Sign up at https://thirdweb.com
2. Navigate to Dashboard → Settings → API Keys
3. Generate a new secret key for Bridge API
4. Copy the secret key (starts with `sk_` or similar)

**Format**:
```bash
THIRDWEB_SECRET_KEY=sk_your_secret_key_here
```

**Usage**:
- Required header: `x-secret-key: $THIRDWEB_SECRET_KEY`
- Used in all thirdweb Bridge API requests

---

### 2. thirdweb Client ID (Optional)

**Variable Name**: `THIRDWEB_CLIENT_ID`

**Description**: Client ID for thirdweb SDK (if using SDK instead of direct API)

**How to Obtain**:
1. thirdweb Dashboard → Settings → API Keys
2. Generate client ID (if available)

**Format**:
```bash
THIRDWEB_CLIENT_ID=your_client_id_here
```

---

## Where to Add These Variables

### Option 1: Main .env File (Recommended)

**File**: `smom-dbis-138/.env`

**Add**:
```bash
# thirdweb Bridge API Configuration
THIRDWEB_SECRET_KEY=sk_your_secret_key_here
THIRDWEB_CLIENT_ID=your_client_id_here  # Optional
```

---

### Option 2: ChainID 138 Environment Template

**File**: `smom-dbis-138/terraform/phases/phase1/config/env.chain138.template`

**Add Section**:
```bash
# thirdweb Bridge API (for WETH → USDT bridging)
THIRDWEB_SECRET_KEY=<your-thirdweb-secret-key>
THIRDWEB_CLIENT_ID=<your-thirdweb-client-id>  # Optional
```

---

### Option 3: Mainnet Environment Template

**File**: `smom-dbis-138/terraform/phases/phase1/config/env.mainnet.template`

**Add Section**:
```bash
# thirdweb Bridge API (for cross-chain bridging)
THIRDWEB_SECRET_KEY=<your-thirdweb-secret-key>
THIRDWEB_CLIENT_ID=<your-thirdweb-client-id>  # Optional
```

---

## Updated Template Files

### env.chain138.template (Updated)

Add this section after line 34:

```bash
# thirdweb Bridge API Configuration
# Get your secret key from: https://thirdweb.com → Dashboard → Settings → API Keys
THIRDWEB_SECRET_KEY=<your-thirdweb-bridge-secret-key>
THIRDWEB_CLIENT_ID=<your-thirdweb-client-id>  # Optional, for SDK usage
```

### env.mainnet.template (Updated)

Add this section after line 35:

```bash
# thirdweb Bridge API Configuration
# Get your secret key from: https://thirdweb.com → Dashboard → Settings → API Keys
THIRDWEB_SECRET_KEY=<your-thirdweb-bridge-secret-key>
THIRDWEB_CLIENT_ID=<your-thirdweb-client-id>  # Optional, for SDK usage
```

---

## Verification

### Check if Variable is Set

```bash
# Check if variable exists
if [ -z "$THIRDWEB_SECRET_KEY" ]; then
    echo "❌ THIRDWEB_SECRET_KEY is not set"
else
    echo "✅ THIRDWEB_SECRET_KEY is set"
fi
```

### Test with Script

```bash
# Load environment
source smom-dbis-138/.env  # or your .env file

# Test bridge quote script
THIRDWEB_SECRET_KEY=$THIRDWEB_SECRET_KEY \
WALLET_ADDRESS=0xYourWallet \
./scripts/test-thirdweb-bridge-with-auth.sh
```

---

## Security Notes

### ⚠️ Important Security Considerations

1. **Never Commit Secrets**:
   - ✅ Add `.env` to `.gitignore`
   - ✅ Use `.env.example` or `.env.template` for templates
   - ❌ Never commit actual secret keys

2. **File Permissions**:
   ```bash
   chmod 600 .env  # Restrictive permissions
   ```

3. **Environment Variable Loading**:
   - Load from `.env` file in scripts
   - Use `source .env` or `export $(grep -v '^#' .env | xargs)`
   - Validate that variables are set before use

4. **Secret Management**:
   - Consider using secret management tools (HashiCorp Vault, AWS Secrets Manager, etc.)
   - Rotate keys regularly
   - Use different keys for development/production

---

## Quick Setup Guide

### Step 1: Get API Key

1. Go to https://thirdweb.com
2. Sign up or log in
3. Navigate to Dashboard → Settings → API Keys
4. Generate new secret key for Bridge API
5. Copy the key

### Step 2: Add to .env File

```bash
# Edit your .env file
nano smom-dbis-138/.env

# Add:
THIRDWEB_SECRET_KEY=sk_your_actual_key_here
```

### Step 3: Update Template Files

```bash
# Update template for ChainID 138
nano smom-dbis-138/terraform/phases/phase1/config/env.chain138.template

# Add thirdweb section (see above)
```

### Step 4: Test

```bash
# Source environment
source smom-dbis-138/.env

# Run test script
./scripts/test-thirdweb-bridge-with-auth.sh
```

---

## Current Configuration Status

| File | Status | Action Needed |
|------|--------|---------------|
| `smom-dbis-138/.env` | ❌ Missing | Add `THIRDWEB_SECRET_KEY` |
| `smom-dbis-138/.env.example` | ❌ Missing | Add template section |
| `env.chain138.template` | ❌ Missing | Add thirdweb section |
| `env.mainnet.template` | ❌ Missing | Add thirdweb section |

---

## Next Steps

1. ✅ **Obtain API Key** from thirdweb dashboard
2. ✅ **Add to .env file** (actual secrets)
3. ✅ **Update template files** (for documentation)
4. ✅ **Test with script** to verify it works
5. ✅ **Check chain/token support** using authenticated API

---

**Last Updated**: 2025-01-27  
**Status**: ❌ **Missing - Needs Configuration**
