Files
smom-dbis-138/docs/deployment/GAS_AND_TOKEN_REQUIREMENTS.md
2026-03-02 12:14:09 -08:00

439 lines
13 KiB
Markdown

# Gas and Token Requirements for Multichain Deployment
**Last Updated**: 2026-02-26 20:12:26 UTC
**Purpose**: Complete breakdown of gas costs and native tokens required for deploying all remaining contracts across all chains
> **⚠️ Real-Time Updates**: This document can be updated with real-time gas prices using:
> ```bash
> ./scripts/deployment/get-multichain-gas-prices.sh
> ./scripts/deployment/update-gas-estimates.sh
> ```
> The estimates below use current market conditions. Always check real-time prices before deployment.
>
> **📖 See**: [Real-Time Gas System](./REAL_TIME_GAS_SYSTEM.md) for complete guide
---
## 📊 Deployment Status Summary
### Ethereum Mainnet (Chain ID: 1)
-**CCIPWETH9Bridge**: Already deployed (`0x3304b747E565a97ec8AC220b0B6A1f6ffDB837e6`)
-**CCIPWETH10Bridge**: Already deployed (`0x8078A09637e47Fa5Ed34F626046Ea2094a5CDE5e`)
-**WETH9**: Already exists (canonical: `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2`)
-**WETH10**: Already exists (canonical: `0xf4BB2e28688e89fCcE3c0580D37d36A7672E8A9f`)
-**CCIPLogger**: **NEEDS DEPLOYMENT**
### Other Chains (Cronos, BSC, Polygon, Gnosis)
-**WETH9**: Needs deployment
-**WETH10**: Needs deployment
-**CCIPWETH9Bridge**: Needs deployment
-**CCIPWETH10Bridge**: Needs deployment
-**CCIPLogger**: Needs deployment
---
## ⛽ Gas Cost Estimates
### Contract Gas Requirements
| Contract | Estimated Gas | Notes |
|----------|---------------|-------|
| **WETH9** | ~450,000 | Simple token contract |
| **WETH10** | ~750,000 | Enhanced WETH with flash loans |
| **CCIPWETH9Bridge** | ~1,800,000 | Complex bridge with CCIP integration |
| **CCIPWETH10Bridge** | ~1,800,000 | Complex bridge with CCIP integration |
| **CCIPLogger** | ~2,500,000 | CCIP receiver with OpenZeppelin dependencies |
### Total Gas per Chain
| Chain | Contracts to Deploy | Total Gas | Buffer (20%) | **Total with Buffer** |
|-------|-------------------|-----------|--------------|----------------------|
| **Ethereum Mainnet** | 1 (CCIPLogger only) | 2,500,000 | 500,000 | **3,000,000** |
| **Cronos** | 5 (all contracts) | 7,300,000 | 1,460,000 | **8,760,000** |
| **BSC** | 5 (all contracts) | 7,300,000 | 1,460,000 | **8,760,000** |
| **Polygon** | 5 (all contracts) | 7,300,000 | 1,460,000 | **8,760,000** |
| **Gnosis** | 5 (all contracts) | 7,300,000 | 1,460,000 | **8,760,000** |
---
## 💰 Native Token Requirements by Chain
### Ethereum Mainnet (ETH)
**Gas Price Sources**:
- **Primary**: Etherscan Gas API v2 (via `ETHERSCAN_API_KEY` in `.env`)
- **Fallback**: RPC endpoint (via `ETH_MAINNET_RPC_URL` in `.env`)
- **Default**: 20 gwei (if APIs unavailable)
**Current Real-Time Estimate** (last run: 2026-01-31):
- **Gas Price**: 2.74 gwei (Etherscan API)
- **Total Gas**: 3,000,000 units
- **Cost**: 0.0082 ETH
- **USD Cost**: ~$20.59 (at $2,500/ETH)
**Refresh**: Run `./scripts/deployment/get-multichain-gas-prices.sh` for latest.
**Gas Price Scenarios** (for reference):
- **Low**: 20 gwei → 0.06 ETH (~$150)
- **Normal**: 50 gwei → 0.15 ETH (~$375)
- **High**: 100 gwei → 0.30 ETH (~$750)
**Recommended Balance**: **0.20 ETH** (covers normal + buffer)
**Token**: ETH (Ethereum)
---
### Cronos (CRO)
**Gas Price Sources**:
- **Primary**: RPC endpoint (via `CRONOS_RPC_URL` in `.env`)
- **Default**: 1,000 gwei (1 gwei in ETH terms) if RPC unavailable
**Current Real-Time Estimate** (run `./scripts/deployment/get-multichain-gas-prices.sh` for latest):
- **Gas Price**: [Fetched from RPC]
- **Total Gas**: 8,760,000 units
- **Cost**: [Calculated from real-time price] CRO
- **USD Cost**: [Calculated from real-time price]
**Gas Price Scenarios** (for reference):
- **Low**: 500 gwei → 4.38 CRO (~$0.35)
- **Normal**: 1,000 gwei → 8.76 CRO (~$0.70)
- **High**: 2,000 gwei → 17.52 CRO (~$1.40)
**Recommended Balance**: **15 CRO** (covers normal + buffer)
**Token**: CRO (Cronos)
---
### BSC / BNB Smart Chain (BNB)
**Gas Price Assumptions**:
- **Low**: 3 gwei
- **Normal**: 5 gwei
- **High**: 10 gwei
| Scenario | Gas Price | Total Gas | Cost (BNB) | Cost (USD @ $300/BNB) |
|----------|-----------|-----------|------------|----------------------|
| **Current** | .05 gwei | 8,760,000 | .0004380000 BNB | $.1314000000 |
| **Normal** | 5 gwei | 8,760,000 | 0.044 BNB | $13.20 |
| **High** | 10 gwei | 8,760,000 | 0.088 BNB | $26.40 |
**Recommended Balance**: **0.06 BNB** (covers normal + buffer)
**Token**: BNB (Binance Coin)
---
### Polygon PoS (MATIC)
**Gas Price Assumptions**:
- **Low**: 30 gwei
- **Normal**: 50 gwei
- **High**: 100 gwei
| Scenario | Gas Price | Total Gas | Cost (MATIC) | Cost (USD @ $0.80/MATIC) |
|----------|-----------|-----------|--------------|-------------------------|
| **Current** | 34.84 gwei | 8,760,000 | .3052138581 MATIC | $.2441710864 |
| **Normal** | 50 gwei | 8,760,000 | 0.44 MATIC | $0.35 |
| **High** | 100 gwei | 8,760,000 | 0.88 MATIC | $0.70 |
**Recommended Balance**: **1.0 MATIC** (covers normal + buffer + verification)
**Token**: MATIC (Polygon)
---
### Gnosis Chain (xDAI)
**Gas Price Assumptions**:
- **Low**: 1 gwei
- **Normal**: 2 gwei
- **High**: 5 gwei
| Scenario | Gas Price | Total Gas | Cost (xDAI) | Cost (USD @ $1.00/xDAI) |
|----------|-----------|-----------|-------------|-------------------------|
| **Current** | 0 gwei | 8,760,000 | .0000235014 xDAI | $.0000235014 |
| **Normal** | 2 gwei | 8,760,000 | 0.0175 xDAI | $0.02 |
| **High** | 5 gwei | 8,760,000 | 0.0438 xDAI | $0.04 |
**Recommended Balance**: **0.05 xDAI** (covers normal + buffer)
**Token**: xDAI (Gnosis Chain native token, pegged to USD)
---
## 📋 Complete Token Requirements Summary
### Minimum Required Balances (Conservative)
| Chain | Native Token | Minimum Balance | Recommended Balance | USD Equivalent (@ current rates) |
|-------|--------------|-----------------|---------------------|--------------------------------|
| **Ethereum Mainnet** | ETH | 0.15 ETH | **0.20 ETH** | $500 |
| **Cronos** | CRO | 8.76 CRO | **15 CRO** | $1.20 |
| **BSC** | BNB | 0.044 BNB | **0.06 BNB** | $18 |
| **Polygon** | MATIC | 0.44 MATIC | **1.0 MATIC** | $0.80 |
| **Gnosis** | xDAI | 0.0175 xDAI | **0.05 xDAI** | $0.05 |
### Total USD Cost Estimate
**At Normal Gas Prices**:
- Ethereum Mainnet: $375
- Cronos: $0.70
- BSC: $13.20
- Polygon: $0.35
- Gnosis: $0.02
- **Total**: ~$389.27
**With Recommended Buffers**:
- Ethereum Mainnet: $500
- Cronos: $1.20
- BSC: $18
- Polygon: $0.80
- Gnosis: $0.05
- **Total**: ~$520.05
---
## 🔍 Contract-Specific Breakdown
### Ethereum Mainnet Deployment
| Contract | Gas Units | Cost @ 50 gwei (ETH) | Cost @ 50 gwei (USD) |
|----------|-----------|---------------------|---------------------|
| CCIPLogger | 2,500,000 | 0.125 ETH | $312.50 |
| **Buffer (20%)** | 500,000 | 0.025 ETH | $62.50 |
| **TOTAL** | **3,000,000** | **0.15 ETH** | **$375.00** |
### Cronos / BSC / Polygon / Gnosis Deployment
| Contract | Gas Units | Notes |
|----------|-----------|-------|
| WETH9 | 450,000 | Simple token contract |
| WETH10 | 750,000 | Enhanced with flash loans |
| CCIPWETH9Bridge | 1,800,000 | Bridge contract |
| CCIPWETH10Bridge | 1,800,000 | Bridge contract |
| CCIPLogger | 2,500,000 | CCIP receiver |
| **Subtotal** | **7,300,000** | |
| **Buffer (20%)** | **1,460,000** | |
| **TOTAL** | **8,760,000** | |
---
## ⚠️ Additional Considerations
### Contract Verification Costs
Contract verification on explorers typically requires:
- **Etherscan**: Free (but may require API key)
- **Cronoscan**: Free
- **BscScan**: Free
- **Polygonscan**: Free
- **Gnosisscan**: Free
**Note**: Verification is free but may require additional transactions for constructor arguments encoding.
### LINK Token Requirements (for CCIP Fees)
After deployment, bridges will need LINK tokens for CCIP cross-chain message fees:
| Chain | LINK Token Address | Recommended Balance |
|-------|-------------------|---------------------|
| **Ethereum Mainnet** | `0x514910771AF9Ca656af840dff83E8264EcF986CA` | 10 LINK |
| **Cronos** | TBD | 10 LINK |
| **BSC** | TBD | 10 LINK |
| **Polygon** | `0x53E0bca35eC356BD5ddDFebbD1Fc0fD03FaBad39` | 10 LINK |
| **Gnosis** | TBD | 10 LINK |
**Total LINK Required**: ~50 LINK (for initial operations and testing)
---
## 🚀 Pre-Deployment Checklist
Before deploying to each chain, verify:
- [ ] **Ethereum Mainnet**: Wallet has ≥ 0.20 ETH
- [ ] **Cronos**: Wallet has ≥ 15 CRO
- [ ] **BSC**: Wallet has ≥ 0.06 BNB
- [ ] **Polygon**: Wallet has ≥ 1.0 MATIC
- [ ] **Gnosis**: Wallet has ≥ 0.05 xDAI
- [ ] All RPC endpoints are accessible
- [ ] All explorer API keys are configured
- [ ] CCIP router addresses are correct for each chain
- [ ] LINK token addresses are correct for each chain
---
## 📝 Environment Variables for Gas Configuration
Add these to your `.env` file:
```bash
# Gas Configuration (optional - Foundry auto-detects)
# Ethereum Mainnet
ETH_MAINNET_GAS_PRICE=50000000000 # 50 gwei
ETH_MAINNET_GAS_LIMIT=3000000
# Cronos
CRONOS_GAS_PRICE=1000000000 # 1000 gwei (1 gwei in ETH terms)
CRONOS_GAS_LIMIT=9000000
# BSC
BSC_GAS_PRICE=5000000000 # 5 gwei
BSC_GAS_LIMIT=9000000
# Polygon
POLYGON_GAS_PRICE=50000000000 # 50 gwei
POLYGON_GAS_LIMIT=9000000
# Gnosis
GNOSIS_GAS_PRICE=2000000000 # 2 gwei
GNOSIS_GAS_LIMIT=9000000
```
---
## 🔄 Real-Time Gas Price Checking
### Automated Script (Recommended)
Use the provided script to fetch real-time gas prices for all chains:
```bash
# Fetch and display real-time gas prices for all chains
./scripts/deployment/get-multichain-gas-prices.sh
# Update documentation with real-time prices
./scripts/deployment/update-gas-estimates.sh
```
This script:
- Fetches gas prices from configured APIs in `.env`
- Calculates costs for all chains
- Updates documentation automatically
- Exports values for use in other scripts
### Manual Checking
Before deployment, you can also check current gas prices manually:
```bash
# Ethereum Mainnet (via Etherscan API)
curl -s "https://api.etherscan.io/v2/api?chainid=1&module=gastracker&action=gasoracle&apikey=${ETHERSCAN_API_KEY}"
# Or via RPC
cast gas-price --rpc-url $ETH_MAINNET_RPC_URL
# Cronos
cast gas-price --rpc-url $CRONOS_RPC_URL
# BSC
cast gas-price --rpc-url $BSC_RPC_URL
# Polygon
cast gas-price --rpc-url $POLYGON_RPC_URL
# Gnosis
cast gas-price --rpc-url $GNOSIS_RPC_URL
```
### Required Environment Variables
Ensure these are set in your `.env` file:
```bash
# Ethereum Mainnet
ETHERSCAN_API_KEY=your_api_key_here
ETH_MAINNET_RPC_URL=https://...
# Other chains
CRONOS_RPC_URL=https://...
BSC_RPC_URL=https://...
POLYGON_RPC_URL=https://...
GNOSIS_RPC_URL=https://...
```
---
## 📊 Cost Optimization Tips
1. **Deploy During Low Activity**: Weekends and off-peak hours typically have lower gas
2. **Monitor Gas Prices**: Use gas trackers before deploying
3. **Batch Deployments**: Deploy multiple contracts in one transaction when possible
4. **Use Gas Tokens**: Some chains support gas tokens (check per chain)
5. **Test on Testnets First**: Verify everything works before mainnet deployment
---
## 🎯 Quick Reference: Minimum Balances
| Chain | Token | Minimum | Recommended |
|-------|-------|---------|-------------|
| **Mainnet** | ETH | 0.15 ETH | **0.20 ETH** |
| **Cronos** | CRO | 8.76 CRO | **15 CRO** |
| **BSC** | BNB | 0.044 BNB | **0.06 BNB** |
| **Polygon** | MATIC | 0.44 MATIC | **1.0 MATIC** |
| **Gnosis** | xDAI | 0.0175 xDAI | **0.05 xDAI** |
---
**Last Updated**: 2026-02-26 20:12:26 UTC
**Next Review**: Before each deployment phase
---
## 📊 Real-Time Gas Price Updates
### How to Update Estimates
1. **Fetch Real-Time Prices**:
```bash
./scripts/deployment/get-multichain-gas-prices.sh
```
2. **Update Documentation**:
```bash
./scripts/deployment/update-gas-estimates.sh
```
3. **Verify Updates**:
- Check `GAS_AND_TOKEN_REQUIREMENTS.md` for updated costs
- Check `TOKENS_AND_CHAINS_SUMMARY.md` for updated balances
- Check `DEPLOYMENT_QUICK_REFERENCE.md` for quick reference
### Gas Price Data Sources
The scripts use the following sources (in priority order):
1. **Ethereum Mainnet**:
- Etherscan Gas API v2 (via `ETHERSCAN_API_KEY`)
- RPC endpoint (via `ETH_MAINNET_RPC_URL`)
- Default: 20 gwei
2. **Other Chains** (Cronos, BSC, Polygon, Gnosis):
- RPC endpoint (via `*_RPC_URL` in `.env`)
- Default: Chain-specific defaults
### Output Format
The script outputs:
- Current gas prices in gwei for each chain
- Deployment costs in native tokens
- USD equivalents (using approximate exchange rates)
- Total estimated cost across all chains
- JSON file with all data for programmatic use
### Exchange Rates (for USD calculations)
Current approximate rates used:
- ETH: $2,500
- CRO: $0.08
- BNB: $300
- MATIC: $0.80
- xDAI: $1.00
**Note**: These rates are approximate. For accurate USD costs, use real-time exchange rates.