Files
aitbc/contracts/scripts/check-gas-price.js
oib 864ef4343e refactor(contracts): remove deprecated AIPowerRental contract in favor of bounty system
- Delete AIPowerRental.sol (566 lines) - replaced by AgentBounty.sol
- Remove rental agreement system with provider/consumer model
- Remove performance metrics and SLA tracking
- Remove dispute resolution mechanism
- Remove ZK-proof verification for performance
- Remove provider/consumer authorization system
- Bounty system provides superior developer incentive structure
2026-02-27 21:46:54 +01:00

48 lines
1.8 KiB
JavaScript

const { ethers } = require("hardhat");
async function main() {
try {
// Get current gas price
const gasPrice = await ethers.provider.getGasPrice();
const gasPriceGwei = ethers.utils.formatUnits(gasPrice, "gwei");
// Get gas limit estimates
const block = await ethers.provider.getBlock("latest");
const baseFeePerGas = block.baseFeePerGas ? ethers.utils.formatUnits(block.baseFeePerGas, "gwei") : "N/A";
// Calculate estimated deployment costs
const estimatedGasLimit = 8000000; // Estimated total gas for all contracts
const estimatedCostEth = parseFloat(gasPriceGwei) * estimatedGasLimit / 1e9;
console.log("🔍 Mainnet Gas Analysis");
console.log("======================");
console.log(`Current Gas Price: ${gasPriceGwei} gwei`);
console.log(`Base Fee: ${baseFeePerGas} gwei`);
console.log(`Estimated Deployment Cost: ${estimatedCostEth.toFixed(4)} ETH`);
console.log(`Estimated Deployment Cost: $${(estimatedCostEth * 2000).toFixed(2)} USD (assuming $2000/ETH)`);
// Gas price recommendations
if (parseFloat(gasPriceGwei) < 20) {
console.log("✅ Gas price is LOW - Good time to deploy");
} else if (parseFloat(gasPriceGwei) < 50) {
console.log("⚠️ Gas price is MODERATE - Consider waiting if possible");
} else {
console.log("❌ Gas price is HIGH - Consider waiting for lower gas");
}
// Output just the gas price for script consumption
console.log(gasPriceGwei);
} catch (error) {
console.error("Error checking gas price:", error);
process.exit(1);
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});