Files
smom-dbis-138/docs/deployment/REAL_TIME_GAS_SYSTEM.md
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

4.7 KiB
Raw Blame History

Real-Time Gas Price System

Last Updated: 2025-01-27

Overview

The multichain deployment system now includes real-time gas price fetching using APIs configured in your .env file. This ensures all cost estimates are based on current market conditions, not outdated static values.

Quick Start

# 1. Ensure .env is configured with API keys and RPC URLs
# 2. Fetch real-time gas prices
./scripts/deployment/get-multichain-gas-prices.sh

# 3. Update all documentation
./scripts/deployment/update-gas-estimates.sh

What Gets Updated

The system updates the following documentation files with real-time gas prices:

  1. GAS_AND_TOKEN_REQUIREMENTS.md

    • Gas price tables for all chains
    • Cost estimates in native tokens
    • USD cost estimates
    • Recommended balances
  2. TOKENS_AND_CHAINS_SUMMARY.md

    • Recommended token balances
    • Cost estimates per chain
    • Total deployment costs
  3. DEPLOYMENT_QUICK_REFERENCE.md

    • Quick reference tables
    • Minimum balances
    • Cost estimates

How It Works

1. Gas Price Fetching

The get-multichain-gas-prices.sh script:

  • Ethereum Mainnet: Uses Etherscan Gas API v2 (via ETHERSCAN_API_KEY)
  • Other Chains: Uses RPC eth_gasPrice calls (via *_RPC_URL variables)
  • Fallbacks: Uses sensible defaults if APIs are unavailable

2. Cost Calculation

For each chain:

Cost (Native Token) = (Gas Units × Gas Price in Wei) / 10^18
Cost (USD) = Cost (Native Token) × Token Price (USD)

3. Documentation Updates

The update-gas-estimates.sh script:

  • Reads gas price data from the fetcher
  • Updates all markdown files with current values
  • Updates timestamps
  • Maintains formatting and structure

Configuration

Required in .env

# Ethereum Mainnet (for Etherscan API)
ETHERSCAN_API_KEY=your_api_key_here
ETH_MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY

# Other Chains (RPC endpoints)
CRONOS_RPC_URL=https://evm.cronos.org
BSC_RPC_URL=https://bsc-dataseed1.binance.org
POLYGON_RPC_URL=https://polygon-rpc.com
GNOSIS_RPC_URL=https://rpc.gnosischain.com

Optional

# Infura Gas API (alternative to Etherscan)
INFURA_GAS_API=your_infura_api_key_here

Example Output

========================================
Multichain Gas Price Fetcher
========================================

Chain ID: 1
Deployer: 0x...
Deployer Balance: 0.5 ETH/Native

Fetching real-time gas prices...
✓ Gas prices fetched

Current Gas Prices:
  Ethereum Mainnet: 25.5 gwei
  Cronos: 1.2 gwei
  BSC: 3.5 gwei
  Polygon: 45.0 gwei
  Gnosis: 2.1 gwei

Deployment Cost Estimates:

Ethereum Mainnet (CCIPLogger only):
  Gas: 3000000 units
  Cost: 0.0765 ETH (~$191.25)

Cronos (all 5 contracts):
  Gas: 8760000 units
  Cost: 10.512 CRO (~$0.84)

...

Total Estimated Cost: ~$520.05 USD

✓ Gas prices saved to /tmp/multichain_gas_prices.json

Integration

Pre-Deployment Workflow

#!/bin/bash
# Pre-deployment checklist

# 1. Fetch real-time gas prices
./scripts/deployment/get-multichain-gas-prices.sh

# 2. Check if costs are acceptable
ETH_COST=$(jq -r '.gas_prices.ethereum_mainnet.cost_eth' /tmp/multichain_gas_prices.json)
if (( $(echo "$ETH_COST > 0.20" | bc -l) )); then
    echo "⚠️  Gas costs are high. Consider waiting."
    exit 1
fi

# 3. Update documentation
./scripts/deployment/update-gas-estimates.sh

# 4. Proceed with deployment
echo "✓ Gas costs acceptable. Proceeding..."

CI/CD Integration

Add to your deployment pipeline:

# .github/workflows/deploy.yml
- name: Fetch Real-Time Gas Prices
  run: |
    ./scripts/deployment/get-multichain-gas-prices.sh
    ./scripts/deployment/update-gas-estimates.sh

Benefits

  1. Accurate Estimates: Always uses current market prices
  2. Automated Updates: No manual calculation needed
  3. Multi-Chain Support: Fetches prices for all 5 chains
  4. Documentation Sync: Keeps all docs in sync automatically
  5. Programmatic Access: JSON output for scripts/automation

Troubleshooting

Script Fails

  1. Check API Keys: echo $ETHERSCAN_API_KEY
  2. Test RPC Endpoints: cast gas-price --rpc-url $ETH_MAINNET_RPC_URL
  3. Check Network: ping -c 1 api.etherscan.io

Documentation Not Updating

  1. Check Permissions: ls -la docs/deployment/*.md
  2. Verify JSON: cat /tmp/multichain_gas_prices.json
  3. Run Manually: Execute scripts step by step

Last Updated: 2025-01-27