- 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.
88 lines
1.8 KiB
Markdown
88 lines
1.8 KiB
Markdown
# Etherscan Gas API v2 Integration
|
|
|
|
## Overview
|
|
|
|
The deployment cost estimation system now uses the correct Etherscan Gas API v2 endpoint for accurate gas price retrieval.
|
|
|
|
## API Endpoint
|
|
|
|
**Correct Endpoint**: `https://api.etherscan.io/v2/api?chainid=1&module=gastracker&action=gasoracle&apikey=YourApiKeyToken`
|
|
|
|
### Response Format
|
|
|
|
```json
|
|
{
|
|
"status": "1",
|
|
"message": "OK",
|
|
"result": {
|
|
"LastBlock": "23788262",
|
|
"SafeGasPrice": "0.111829336",
|
|
"ProposeGasPrice": "0.11182936",
|
|
"FastGasPrice": "0.123012296",
|
|
"suggestBaseFee": "0.111829336",
|
|
"gasUsedRatio": "..."
|
|
}
|
|
}
|
|
```
|
|
|
|
## Integration
|
|
|
|
### Gas Price Sources (Priority Order)
|
|
|
|
1. **MetaMask** (via `ETHEREUM_MAINNET_RPC`)
|
|
2. **Etherscan Gas API v2** (via `ETHERSCAN_API_KEY`)
|
|
3. **Default RPC** (fallback)
|
|
|
|
### Methodology
|
|
|
|
```
|
|
Conservative Gas Price = MIN(MAX(MetaMask Gas, Etherscan Gas), 2.5 gwei)
|
|
```
|
|
|
|
- Fetches from both MetaMask and Etherscan
|
|
- Selects the **highest** price
|
|
- Caps at **2.5 gwei maximum**
|
|
|
|
## Usage
|
|
|
|
### Get Conservative Gas Price
|
|
|
|
```bash
|
|
./scripts/deployment/get-conservative-gas-price.sh
|
|
```
|
|
|
|
### Calculate Costs
|
|
|
|
```bash
|
|
./scripts/deployment/calculate-conservative-costs.sh
|
|
```
|
|
|
|
### Test API
|
|
|
|
```bash
|
|
./scripts/deployment/test-etherscan-gas-api.sh
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Add to `.env`:
|
|
|
|
```env
|
|
ETHERSCAN_API_KEY=your_api_key_here
|
|
ETHEREUM_MAINNET_RPC=https://...
|
|
```
|
|
|
|
## Current Status
|
|
|
|
- ✅ API endpoint corrected to v2 format
|
|
- ✅ Response parsing handles both v1 and v2 formats
|
|
- ✅ Gas price extraction working correctly
|
|
- ✅ Display formatting improved
|
|
- ✅ Conservative calculation using 2.5 gwei cap
|
|
|
|
## Notes
|
|
|
|
- Current gas prices (~0.1 gwei) are extremely low and not normal
|
|
- System uses actual prices when below 2.5 gwei cap
|
|
- For budgeting, consider normal market conditions (30-50 gwei)
|