laconicd-stack/stack-orchestrator/config/mainnet-laconicd/create-validator.sh

57 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
DENOM=alnt
NODE_HOME=/root/.laconicd
KEYRING="test"
staking_amount_file="$NODE_HOME/tmp/staking-amount.json"
if [ ! -f "$staking_amount_file" ]; then
echo "staking-amount.json file not provided, exiting..."
exit 1
fi
if [-z "$KEY_NAME" ]; then
echo "KEY_NAME environment variable not set, exiting..."
exit 1
fi
if [ -z "$CERC_MONIKER" ]; then
echo "CERC_MONIKER environment variable not set, exiting..."
exit 1
fi
if [ -z "$NODE_URL" ]; then
echo "NODE_URL environment variable not set, exiting..."
exit 1
fi
# Set staking amount
stake_amount=$(jq -r '.common_staking_amount' "$staking_amount_file")
# Create validator.json file
validator_json="$NODE_HOME/tmp/validator.json"
cat > "$validator_json" << EOF
{
"pubkey": $(laconicd tendermint show-validator),
"amount": "${stake_amount}${DENOM}",
"moniker": "${CERC_MONIKER}",
"commission-rate": "0.0",
"commission-max-rate": "0.0",
"commission-max-change-rate": "0.0",
"min-self-delegation": "1"
}
EOF
# Create validator using the JSON file
laconicd tx staking create-validator "$validator_json" \
--chain-id "$CERC_CHAIN_ID" \
--gas auto \
--gas-adjustment 1.5 \
--gas-prices $MIN_GAS_PRICE$DENOM \
--from $KEY_NAME \
--keyring-backend $KEYRING \
--node $NODE_URL \
--yes