Skip to content

Instantly share code, notes, and snippets.

@rkrasiuk
Created September 29, 2023 11:55
Show Gist options
  • Save rkrasiuk/e71f4671841b00d2ecf8099132df71f6 to your computer and use it in GitHub Desktop.
Save rkrasiuk/e71f4671841b00d2ecf8099132df71f6 to your computer and use it in GitHub Desktop.
Beacon Chain Deposits
#!/bin/bash
read -p "Are you sure? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
if [[ -z $1 ]]; then
echo "need path to deposit json file. usage \`deposit.sh <deposit.json>\`"
exit 1 || return 1
fi
if [[ -z "${DEPOSIT_CONTRACT_ADDRESS}" ]]; then
echo "need DEPOSIT_CONTRACT_ADDRESS environment var"
exit 1 || return 1
fi
if [[ -z "${PRIVATE_KEY}" ]]; then
echo "need PRIVATE_KEY environment var"
exit 1 || return 1
fi
jq -c '.[]' $1 | while read x; do
pubkey="$(echo "$x" | jq -r .pubkey )"
withdrawal_credentials="$(echo "$x" | jq -r .withdrawal_credentials)"
signature="$(echo "$x" | jq -r .signature)"
deposit_data_root="$(echo "$x" | jq -r .deposit_data_root)"
cast send $DEPOSIT_CONTRACT_ADDRESS 'deposit(bytes,bytes,bytes,bytes32)' \
$pubkey $withdrawal_credentials $signature $deposit_data_root \
--value 32ether --private-key $PRIVATE_KEY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment