-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathgenerate-deposit-tx.sh
More file actions
executable file
·63 lines (47 loc) · 2.98 KB
/
Copy pathgenerate-deposit-tx.sh
File metadata and controls
executable file
·63 lines (47 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
source env.sh;
STAKE_AMOUNT_GWEI=$(($STAKE_AMOUNT_ETH * 1000000000));
echo "Starting Beacon Deposit Txn...";
set -e;
if [ -z "$NUM_RPC_NODES" ] || [ $NUM_RPC_NODES -eq 0 ]; then
echo "No RPC nodes set. Exiting...";
exit 1;
fi
# Step 0 - Retrieve Validator Pubkey
COMETBFT_PUB_KEY=$(docker exec $CL_MONIKER-rpc-0 beacond deposit validator-keys|tail -1);
echo "Obtained validator pubkey: $COMETBFT_PUB_KEY";
GENESIS_ROOT=$(docker exec $CL_MONIKER-rpc-0 beacond genesis validator-root /root/.beacond/config/genesis.json);
echo "Obtained genesis root: $GENESIS_ROOT";
docker >/dev/null exec $CL_MONIKER-rpc-0 beacond genesis validator-root /root/.beacond/config/genesis.json;
docker >/dev/null exec $CL_MONIKER-val-1 beacond genesis validator-root /root/.beacond/config/genesis.json;
# Step 1 - Generate Deposit Signature
echo -e "\nGenerating Signature for Parameters: \n\tpubkey = $COMETBFT_PUB_KEY \n\tamount = $STAKE_AMOUNT_GWEI \n\tgenesis_root = $GENESIS_ROOT \n\twithdraw_address = $WITHDRAW_ADDRESS";
WITHDRAW_CREDENTIAL=$(docker exec $CL_MONIKER-rpc-0 beacond deposit create-validator $WITHDRAW_ADDRESS $STAKE_AMOUNT_GWEI -g $GENESIS_ROOT | sed -n 's/credentials: //p');
DEPOSIT_SIGNATURE=$(docker exec $CL_MONIKER-rpc-0 beacond deposit create-validator $WITHDRAW_ADDRESS $STAKE_AMOUNT_GWEI -g $GENESIS_ROOT | sed -n 's/signature: //p');
DEPOSIT_TX_VALID=$(docker exec $CL_MONIKER-rpc-0 beacond deposit validate $COMETBFT_PUB_KEY $WITHDRAW_CREDENTIAL $STAKE_AMOUNT_GWEI $DEPOSIT_SIGNATURE -g $GENESIS_ROOT);
if [ "✅ Deposit message is valid!" != "$DEPOSIT_TX_VALID" ]; then
echo -e "Deposit signature is invalid! Exiting...";
exit 1;
fi
# Give deposit registration cast
echo -e "\n\nSend this command to register the validator + deposit $STAKE_AMOUNT_ETH BERA: \n\t";
echo cast send $BEACONDEPOSIT_ADDRESS \'deposit\(bytes,bytes,bytes,address\)\' \
$COMETBFT_PUB_KEY $WITHDRAW_CREDENTIAL $DEPOSIT_SIGNATURE $OPERATOR_ADDRESS \
--value "${STAKE_AMOUNT_ETH}ether" \
--private-key $WALLET_PRIVATE_KEY \
--rpc-url $RPC_URL;
# Give deposit activation cast
echo -e "\n\nSend this command to activate the validator by depositing $REMAINING_STAKE_AMOUNT_ETH BERA: \n\t";
echo cast send $BEACONDEPOSIT_ADDRESS \'deposit\(bytes,bytes,bytes,address\)\' \
"$COMETBFT_PUB_KEY" \
"0x0000000000000000000000000000000000000000000000000000000000000000" \
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" \
"0x0000000000000000000000000000000000000000" \
--private-key $WALLET_PRIVATE_KEY \
--value "${REMAINING_STAKE_AMOUNT_ETH}ether" \
--rpc-url $RPC_URL;
echo -e "\n\nSTATUS COMMANDS\n"
echo -e "Check the funding wallet balance (BERA):";
echo -e "cast balance $WITHDRAW_ADDRESS --rpc-url $RPC_URL | cast --from-wei";
echo -e "Send this command to view validators:";
echo -e "curl -s http://localhost:3500/eth/v1/beacon/states/head/validators | jq .data";