Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
2.0 KiB
Bash
Executable File
58 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Optimize gas usage for bridge operations
|
|
# Usage: ./optimize-gas-usage.sh
|
|
|
|
set -euo pipefail
|
|
|
|
# Load IP configuration
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SOURCE_PROJECT="/home/intlc/projects/smom-dbis-138"
|
|
|
|
source "$SOURCE_PROJECT/.env" 2>/dev/null || true
|
|
|
|
RPC_URL="${RPC_URL_138_PUBLIC:-http://${RPC_PUBLIC_1:-192.168.11.221}:8545}"
|
|
|
|
# Get optimal gas price based on network conditions
|
|
get_optimal_gas_price() {
|
|
local current_gas=$(cast gas-price --rpc-url "$RPC_URL" 2>/dev/null || echo "1000000000")
|
|
local multiplier=1.2 # Use 1.2x for optimal balance between speed and cost
|
|
echo "scale=0; $current_gas * $multiplier / 1" | bc
|
|
}
|
|
|
|
# Estimate gas for operation
|
|
estimate_gas() {
|
|
local contract="$1"
|
|
local function="$2"
|
|
local args="$3"
|
|
|
|
cast estimate "$contract" "$function" $args --rpc-url "$RPC_URL" 2>/dev/null || echo "0"
|
|
}
|
|
|
|
# Batch operations to reduce gas
|
|
batch_operations() {
|
|
echo "=== Gas Optimization Strategies ==="
|
|
echo ""
|
|
echo "1. Use optimal gas price: $(echo "scale=2; $(get_optimal_gas_price) / 1000000000" | bc) gwei"
|
|
echo "2. Batch multiple approvals into single transaction when possible"
|
|
echo "3. Use gas estimation before sending transactions"
|
|
echo "4. Send transactions during low network congestion"
|
|
echo ""
|
|
|
|
# Get current gas price
|
|
local current_gas=$(cast gas-price --rpc-url "$RPC_URL" 2>/dev/null || echo "1000000000")
|
|
local optimal_gas=$(get_optimal_gas_price)
|
|
|
|
echo "Current Network Gas: $(echo "scale=2; $current_gas / 1000000000" | bc) gwei"
|
|
echo "Optimal Gas Price: $(echo "scale=2; $optimal_gas / 1000000000" | bc) gwei"
|
|
echo ""
|
|
echo "Recommendation: Use $(echo "scale=2; $optimal_gas / 1000000000" | bc) gwei for transactions"
|
|
}
|
|
|
|
batch_operations
|
|
|