Files
proxmox/scripts/bridge/fund-bsc-relay-bridge.sh
defiQUG dc68ae8072 chore: BSC relay fund script, CCIP RTT report, NPM proxy fixes, submodule
- Add scripts/bridge/fund-bsc-relay-bridge.sh (mirror mainnet helper)
- Add reports/ccip-rtt-138-bsc-source-execution-2026-03-24.json (5/5 baseline)
- update-npmplus-proxy-hosts-api: case-insensitive host id, refresh on miss,
  recover duplicate POST via PUT, add-if-missing for dbis-api-2, secure, mim4u*
- smom-dbis-138: relay log chunking, START_BLOCK parsing, README, .env.bsc.example

Made-with: Cursor
2026-03-24 16:18:29 -07:00

63 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fund the BSC CCIPRelayBridge with WETH from the deployer wallet.
# Usage: ./scripts/bridge/fund-bsc-relay-bridge.sh [amount_wei] [--dry-run]
# If amount_wei is omitted, transfers the deployer's full WETH balance.
# --dry-run: print balances and amount that would be sent; do not broadcast.
# Env: PRIVATE_KEY (not required for --dry-run), BSC_RPC_URL or DEST_RPC_URL from relay profile
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
[[ -f "${PROJECT_ROOT}/smom-dbis-138/.env" ]] && source "${PROJECT_ROOT}/smom-dbis-138/.env" 2>/dev/null || true
# Optional: DEST_RPC_URL from relay .env.bsc (not auto-sourced; user may export)
if [[ -f "${PROJECT_ROOT}/smom-dbis-138/services/relay/.env.bsc" ]]; then
# shellcheck disable=SC1090
source "${PROJECT_ROOT}/smom-dbis-138/services/relay/.env.bsc" 2>/dev/null || true
fi
DRY_RUN=false
ARGS=()
for a in "$@"; do
[[ "$a" = "--dry-run" ]] && DRY_RUN=true || ARGS+=("$a")
done
DEPLOYER="${DEPLOYER_ADDRESS:-0x4A666F96fC8764181194447A7dFdb7d471b301C8}"
WETH="${DEST_WETH9_ADDRESS:-0xe0E93247376aa097dB308B92e6Ba36bA015535D0}"
BRIDGE="${DEST_RELAY_BRIDGE:-0x886C6A4ABC064dbf74E7caEc460b7eeC31F1b78C}"
RPC="${BSC_RPC_URL:-${DEST_RPC_URL:-https://bsc.publicnode.com}}"
[[ "$DRY_RUN" = true ]] || [[ -n "${PRIVATE_KEY:-}" ]] || { echo "PRIVATE_KEY required"; exit 1; }
command -v cast &>/dev/null || { echo "cast not found (install Foundry)"; exit 1; }
BALANCE=$(cast call "$WETH" "balanceOf(address)(uint256)" "$DEPLOYER" --rpc-url "$RPC" 2>/dev/null || echo "0")
BRIDGE_BAL=$(cast call "$WETH" "balanceOf(address)(uint256)" "$BRIDGE" --rpc-url "$RPC" 2>/dev/null || echo "0")
echo "Deployer WETH balance (BSC): $BALANCE wei"
echo "Bridge WETH balance (BSC): $BRIDGE_BAL wei"
if [[ "${ARGS[0]:-}" = "" ]]; then
AMT="$BALANCE"
echo "Would transfer full balance: $AMT wei"
else
AMT="${ARGS[0]}"
echo "Would transfer: $AMT wei"
fi
if [[ -z "$AMT" ]] || [[ "$AMT" = "0" ]]; then
echo "Nothing to transfer."
[[ "$DRY_RUN" = true ]] && echo "[--dry-run] No tx would be sent."
exit 0
fi
if [[ "$DRY_RUN" = true ]]; then
echo "[--dry-run] Would run: cast send $WETH transfer(address,uint256) $BRIDGE $AMT --rpc-url <RPC> --private-key <PRIVATE_KEY> --legacy"
echo "[--dry-run] No transaction sent."
exit 0
fi
cast send "$WETH" "transfer(address,uint256)" "$BRIDGE" "$AMT" \
--rpc-url "$RPC" \
--private-key "$PRIVATE_KEY" \
--legacy
echo "Done. Bridge WETH balance: $(cast call "$WETH" "balanceOf(address)(uint256)" "$BRIDGE" --rpc-url "$RPC") wei"