- 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.
6.0 KiB
6.0 KiB
Gas API Integration Summary
Date: 2025-01-27 Status: ✅ Complete
What Was Implemented
A complete real-time gas price fetching and documentation update system for multichain deployment.
New Scripts Created
1. scripts/deployment/get-multichain-gas-prices.sh
Purpose: Fetches real-time gas prices for all chains using APIs from .env
Features:
- Fetches gas prices from Etherscan API (Ethereum Mainnet)
- Fetches gas prices from RPC endpoints (all chains)
- Calculates deployment costs in native tokens
- Calculates USD equivalents
- Exports environment variables
- Saves JSON output for programmatic access
Usage:
./scripts/deployment/get-multichain-gas-prices.sh
2. scripts/deployment/update-gas-estimates.sh
Purpose: Updates all documentation files with real-time gas prices
Features:
- Reads gas price data from
get-multichain-gas-prices.sh - Updates
GAS_AND_TOKEN_REQUIREMENTS.md - Updates
TOKENS_AND_CHAINS_SUMMARY.md - Updates
DEPLOYMENT_QUICK_REFERENCE.md - Updates timestamps in all files
Usage:
./scripts/deployment/update-gas-estimates.sh
Updated Documentation
1. GAS_AND_TOKEN_REQUIREMENTS.md
- Added real-time gas price update instructions
- Updated gas price sections to reference API sources
- Added automated update workflow
- Added exchange rate notes
2. MULTICHAIN_DEPLOYMENT_RUNBOOK.md
- Added real-time gas price fetching step
- Updated minimum balance recommendations
- Added reference to gas requirements document
3. ENV_EXAMPLE_CONTENT.md
- Added gas API configuration section
- Added Etherscan API key documentation
- Added Infura Gas API option
- Added instructions for real-time updates
4. New Documentation Created
REAL_TIME_GAS_UPDATES.md- Complete guide for real-time updatesREAL_TIME_GAS_SYSTEM.md- System overview and quick startGAS_API_INTEGRATION_SUMMARY.md- This document
Gas Price Sources
Ethereum Mainnet
-
Etherscan Gas API v2 (Primary)
- Endpoint:
https://api.etherscan.io/v2/api?chainid=1&module=gastracker&action=gasoracle&apikey={KEY} - Requires:
ETHERSCAN_API_KEYin.env - Returns: FastGasPrice, ProposeGasPrice, SafeGasPrice
- Endpoint:
-
RPC Endpoint (Fallback)
- Uses:
eth_gasPriceRPC call - Requires:
ETH_MAINNET_RPC_URLin.env
- Uses:
-
Default (Final Fallback)
- 20 gwei if all APIs fail
Other Chains (Cronos, BSC, Polygon, Gnosis)
-
RPC Endpoint (Primary)
- Uses:
eth_gasPriceRPC call - Requires:
*_RPC_URLin.env
- Uses:
-
Default (Fallback)
- Chain-specific defaults
Required Environment Variables
Add to .env:
# Ethereum Mainnet
ETHERSCAN_API_KEY=your_etherscan_api_key_here
ETH_MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
# Other Chains
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
Workflow
Before Deployment
-
Configure
.env:cp .env.example .env # Edit .env with your API keys and RPC URLs -
Fetch Real-Time Prices:
./scripts/deployment/get-multichain-gas-prices.sh -
Update Documentation:
./scripts/deployment/update-gas-estimates.sh -
Review Estimates:
- Check updated documentation
- Verify costs are acceptable
- Ensure wallet balances are sufficient
-
Deploy:
# Proceed with deployment using updated estimates
Output Format
Console Output
- Current gas prices for all chains
- Deployment costs in native tokens
- USD equivalents
- Total estimated cost
JSON Output
Saved to /tmp/multichain_gas_prices.json:
{
"timestamp": "2025-01-27 12:00:00 UTC",
"gas_prices": {
"ethereum_mainnet": { ... },
"cronos": { ... },
"bsc": { ... },
"polygon": { ... },
"gnosis": { ... }
},
"total_usd": "520.05"
}
Environment Variables
Exported for use in other scripts:
ETH_GAS_WEI,ETH_GAS_GWEI,ETH_COST,ETH_USD_COSTCRONOS_GAS_WEI,CRONOS_COST,CRONOS_USD_COSTBSC_GAS_WEI,BSC_COST,BSC_USD_COSTPOLYGON_GAS_WEI,POLYGON_COST,POLYGON_USD_COSTGNOSIS_GAS_WEI,GNOSIS_COST,GNOSIS_USD_COSTTOTAL_USD
Benefits
- Always Current: Uses real-time gas prices, not outdated estimates
- Automated: No manual calculation needed
- Multi-Chain: Supports all 5 chains simultaneously
- Documentation Sync: Keeps all docs automatically updated
- Programmatic: JSON output for automation/CI/CD
- Transparent: Shows exactly where prices come from
Testing
To test the system:
# 1. Ensure .env is configured
cat .env | grep -E "ETHERSCAN_API_KEY|.*_RPC_URL"
# 2. Test gas price fetching
./scripts/deployment/get-multichain-gas-prices.sh
# 3. Verify JSON output
cat /tmp/multichain_gas_prices.json | jq .
# 4. Test documentation update
./scripts/deployment/update-gas-estimates.sh
# 5. Verify documentation was updated
grep -A 5 "Current Real-Time Estimate" docs/deployment/GAS_AND_TOKEN_REQUIREMENTS.md
Dependencies
- cast (Foundry) - For RPC gas price calls
- bc - For calculations
- curl - For API calls
- jq (optional) - For JSON parsing in scripts
Next Steps
- Configure
.env: Add all required API keys and RPC URLs - Test Scripts: Run the scripts to verify they work
- Update Documentation: Run update script to populate real-time values
- Review Estimates: Check that costs are reasonable
- Deploy: Use updated estimates for deployment planning
Related Files
scripts/deployment/get-multichain-gas-prices.sh- Gas price fetcherscripts/deployment/update-gas-estimates.sh- Documentation updaterdocs/deployment/GAS_AND_TOKEN_REQUIREMENTS.md- Cost breakdowndocs/deployment/REAL_TIME_GAS_SYSTEM.md- System overviewdocs/deployment/REAL_TIME_GAS_UPDATES.md- Detailed guide
Status: ✅ Ready for use Last Updated: 2025-01-27