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] |
| 8 | source "$(dirname "$0")/lib.sh" |
| 9 | AMOUNT=${1:-0.01} |
| 10 | AMOUNT=${AMOUNT%ether} |
| 11 | ROLE=${2:-sender} |
| 12 | [[ "$AMOUNT" =~ ^[0-9]*\.?[0-9]+$ ]] || die "usage: [FORK=<port>] $0 [amount in ETH, e.g. 0.01] [sender|sweeper|approver|emergency]" |
| 13 | case "$ROLE" in sender | sweeper | approver | emergency) ;; *) die "role must be sender, sweeper, approver or emergency" ;; esac |
| 14 | check_rpc |
| 15 | OWNER=$(addr_of owner) |
| 16 | TO=$(addr_of "$ROLE") |
| 17 | WEI=$(cast to-wei "$AMOUNT" ether) |
| 18 | OBAL=$(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")" |
| 20 | say "owner $OWNER -> $ROLE $TO: $(cast from-wei "$WEI") ETH on $NET" |
| 21 | RCPT=$(send_as owner "$TO" --value "$WEI") |
| 22 | TX=$(jq -r .transactionHash <<<"$RCPT") |
| 23 | [ "$(jq -r .status <<<"$RCPT")" = 0x1 ] || die "transfer failed: $(tx_ref "$TX")" |
| 24 | BAL=$(cast balance "$TO" --rpc-url "$RPC") |
| 25 | GP=$(cast gas-price --rpc-url "$RPC") |
| 26 | say " tx $(tx_ref "$TX")" |
| 27 | say " $ROLE balance now $(cast from-wei "$BAL") ETH; owner $(cast from-wei "$(cast balance "$OWNER" --rpc-url "$RPC")") ETH" |
| 28 | if { [ "$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)" |
| 32 | fi |
| 33 | exit 0 |