Source mirror · commit 369512f · 2026-10-26 · MIT · canonical repo: gitlab.com/jiapunk/upgrade-airlock
git clone https://upgrade-airlock.pages.dev/source/upgrade-airlock.git
upgrade-airlock / scripts / sepolia / fund-sender.sh
scripts/sepolia/fund-sender.sh33 lines · 1915 bytes
1#!/usr/bin/env bash
2# The owner sends a little Sepolia ETH to the report sender (the key that pays the CRE writeReport transactions),
3# or to another demo key that sends transactions (sweeper.key when the sweeper pays its own reports, the approver
4# for clear.sh, the emergency guardian).
5#
6# scripts/sepolia/fund-sender.sh [eth] [sender|sweeper|approver|emergency] # default 0.01 ETH to the sender
7# FORK=19631 scripts/sepolia/fund-sender.sh [eth] [role]
8source "$(dirname "$0")/lib.sh"
9AMOUNT=${1:-0.01}
10AMOUNT=${AMOUNT%ether}
11ROLE=${2:-sender}
12[[ "$AMOUNT" =~ ^[0-9]*\.?[0-9]+$ ]] || die "usage: [FORK=<port>] $0 [amount in ETH, e.g. 0.01] [sender|sweeper|approver|emergency]"
13case "$ROLE" in sender | sweeper | approver | emergency) ;; *) die "role must be sender, sweeper, approver or emergency" ;; esac
14check_rpc
15OWNER=$(addr_of owner)
16TO=$(addr_of "$ROLE")
17WEI=$(cast to-wei "$AMOUNT" ether)
18OBAL=$(cast balance "$OWNER" --rpc-url "$RPC")
19[ "$(bc <<<"$OBAL > $WEI")" = 1 ] || die "owner $OWNER has $(cast from-wei "$OBAL") ETH, cannot send $(cast from-wei "$WEI")"
20say "owner $OWNER -> $ROLE $TO: $(cast from-wei "$WEI") ETH on $NET"
21RCPT=$(send_as owner "$TO" --value "$WEI")
22TX=$(jq -r .transactionHash <<<"$RCPT")
23[ "$(jq -r .status <<<"$RCPT")" = 0x1 ] || die "transfer failed: $(tx_ref "$TX")"
24BAL=$(cast balance "$TO" --rpc-url "$RPC")
25GP=$(cast gas-price --rpc-url "$RPC")
26say " tx $(tx_ref "$TX")"
27say " $ROLE balance now $(cast from-wei "$BAL") ETH; owner $(cast from-wei "$(cast balance "$OWNER" --rpc-url "$RPC")") ETH"
28if { [ "$ROLE" = sender ] || [ "$ROLE" = sweeper ]; } && [ "$GP" -gt 0 ]; then
29 GL=2000000
30 [ "$MODE" = live ] && [ -f "$ROOT/cre/veto/config.sepolia.json" ] && GL=$(jq -r '.gasLimit // 2000000' "$ROOT/cre/veto/config.sepolia.json")
31 say " at $GP wei/gas that covers ~$(bc <<<"$BAL / ($GL * $GP)") reports of $GL gas (the config's writeReport gas limit)"
32fi
33exit 0