# Token Deployment Quick Start Guide

**Date**: 2025-12-24  
**Purpose**: Quick reference for deploying tokens on ChainID 138

---

## 🚀 Quick Deployment Commands

### 1. Deploy USDT Token

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

# Set environment variables (optional)
export USDT_OWNER=0x4A666F96fC8764181194447A7dFdb7d471b301C8
export USDT_INITIAL_SUPPLY=1000000000000  # 1M USDT (6 decimals)

# Deploy
forge script script/DeployUSDT.s.sol:DeployUSDT \
  --rpc-url http://192.168.11.250:8545 \
  --broadcast \
  --legacy \
  --gas-price 20000000000 \
  -vv
```

### 2. Deploy USDC Token

```bash
# Set environment variables (optional)
export USDC_OWNER=0x4A666F96fC8764181194447A7dFdb7d471b301C8
export USDC_INITIAL_SUPPLY=1000000000000  # 1M USDC (6 decimals)

# Deploy
forge script script/DeployUSDC.s.sol:DeployUSDC \
  --rpc-url http://192.168.11.250:8545 \
  --broadcast \
  --legacy \
  --gas-price 20000000000 \
  -vv
```

### 3. Deploy Governance Token

```bash
# Set environment variables (optional)
export GOV_TOKEN_OWNER=0x4A666F96fC8764181194447A7dFdb7d471b301C8
export GOV_TOKEN_NAME="DBIS Token"
export GOV_TOKEN_SYMBOL="DBIS"
export GOV_TOKEN_INITIAL_SUPPLY=400000000000000000000000000  # 400M tokens (40% of max)

# Deploy
forge script script/DeployGovernanceToken.s.sol:DeployGovernanceToken \
  --rpc-url http://192.168.11.250:8545 \
  --broadcast \
  --legacy \
  --gas-price 20000000000 \
  --via-ir \
  -vv
```

---

## 📋 Prerequisites

### 1. Install OpenZeppelin Contracts

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

# Initialize git if not already
git init

# Install OpenZeppelin
forge install OpenZeppelin/openzeppelin-contracts

# Verify installation
ls -la lib/openzeppelin-contracts
```

### 2. Update foundry.toml

Ensure `remappings.txt` includes:
```
@openzeppelin/=lib/openzeppelin-contracts/
```

### 3. Set Environment Variables

Add to `.env`:
```bash
# Token Deployment
USDT_OWNER=0x4A666F96fC8764181194447A7dFdb7d471b301C8
USDT_INITIAL_SUPPLY=0  # 0 = no initial supply, mint on-demand

USDC_OWNER=0x4A666F96fC8764181194447A7dFdb7d471b301C8
USDC_INITIAL_SUPPLY=0

GOV_TOKEN_OWNER=0x4A666F96fC8764181194447A7dFdb7d471b301C8
GOV_TOKEN_NAME="DBIS Token"
GOV_TOKEN_SYMBOL="DBIS"
GOV_TOKEN_INITIAL_SUPPLY=0
```

---

## ✅ Post-Deployment Steps

### 1. Verify Contract on Block Explorer

```bash
# Get deployed address from broadcast log
cast code <DEPLOYED_ADDRESS> --rpc-url http://192.168.11.250:8545

# Should return bytecode (not empty)
```

### 2. Update Environment Variables

Add to `.env`:
```bash
USDT_ADDRESS=<deployed_address>
USDC_ADDRESS=<deployed_address>
GOV_TOKEN_ADDRESS=<deployed_address>
```

### 3. Add to Token Lists

Update `token-lists/lists/dbis-138.tokenlist.json`:
```json
{
  "chainId": 138,
  "address": "<deployed_address>",
  "name": "Tether USD",
  "symbol": "USDT",
  "decimals": 6,
  "logoURI": "https://..."
}
```

### 4. Update Database

Run migration or insert:
```sql
INSERT INTO tokens (address, symbol, name, decimals, chain_id)
VALUES (
    '<deployed_address>',
    'USDT',
    'Tether USD',
    6,
    138
);
```

### 5. Configure Oracle Price Feeds

```bash
# Add USDT/USD price feed to Oracle Aggregator
cast send <ORACLE_AGGREGATOR_ADDRESS> \
  "setAggregator(address,address,uint256)" \
  <USDT_ADDRESS> \
  <PRICE_FEED_ADDRESS> \
  <DEVIATION_THRESHOLD> \
  --rpc-url http://192.168.11.250:8545 \
  --private-key $PRIVATE_KEY
```

---

## 🔒 Security Checklist

- [ ] Multi-signature wallet set up for token ownership
- [ ] Security audit completed (for native stablecoins)
- [ ] Pausable functionality tested
- [ ] Access control verified
- [ ] Initial supply distribution planned
- [ ] Monitoring and alerts configured

---

## 📊 Cost Estimates

- **USDT Deployment**: ~0.02 ETH
- **USDC Deployment**: ~0.02 ETH
- **Governance Token**: ~0.02 ETH
- **Total**: ~0.06 ETH

---

## 🆘 Troubleshooting

### OpenZeppelin Not Found

```bash
# Install OpenZeppelin
forge install OpenZeppelin/openzeppelin-contracts

# Update remappings
echo "@openzeppelin/=lib/openzeppelin-contracts/" >> remappings.txt
```

### Compilation Errors

```bash
# Clean and rebuild
forge clean
forge build --via-ir
```

### Deployment Fails

```bash
# Check balance
cast balance <DEPLOYER_ADDRESS> --rpc-url http://192.168.11.250:8545

# Check gas price
cast gas-price --rpc-url http://192.168.11.250:8545

# Increase gas price if needed
forge script ... --gas-price 50000000000
```

---

## 📚 Additional Resources

- **Full Recommendations**: `docs/STABLECOIN_AND_TOKEN_RECOMMENDATIONS.md`
- **Missing Contracts**: `docs/MISSING_CONTRACTS_COMPREHENSIVE_LIST.md`
- **Deployed Contracts**: `docs/DEPLOYED_CONTRACTS_REVIEW.md`

---

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

