forked from matsuro-hadouken/casper-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bond.sh
executable file
·54 lines (38 loc) · 1.69 KB
/
bond.sh
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
#!/bin/bash
# Bond validat to networks
# Requirements: 'apt install jq'
# Requirements: Set 'validator public hex' , 'BID_AMOUNT' , 'PROFIT ( fee ), 'CHAIN_NAME', 'OWNER_PRIVATE_KEY' path, 'API' end pint, 'BONDING_CONTRACT' path.
BID_AMOUNT="10000000000" # AMOUNT 'IN MOTES' ( 10 CSPR MINIMUM )
payment_amount="3000000000" # TRANSACTION FEE 'IN MOTES'
validator_comission="50" # COMISSION RATE PERCENTAGE
CHAIN_NAME=`curl -s localhost:8888/status | jq -r .chainspec_name`
public_hex_path='/etc/casper/validator_keys/public_key_hex'
OWNER_PRIVATE_KEY="/etc/casper/validator_keys/secret_key.pem"
API_HOST="http://127.0.0.1:7777"
BONDING_CONTRACT="$HOME/casper-node/target/wasm32-unknown-unknown/release/add_bid.wasm"
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m'
PUB_KEY_HEX="$1"
function GetPublicHEX() {
AutoHEX=$(cat "$public_hex_path")
if [ -z "$PUB_KEY_HEX" ]; then
PUB_KEY_HEX="$AutoHEX"
echo && echo -e "${RED}No valid manual input detected !${NC}" && echo
echo -e "Using public HEX from: ${RED}$public_hex_path${NC}"
fi
echo && echo -e "Public HEX: ${CYAN}$PUB_KEY_HEX${NC}"
}
GetPublicHEX
echo && echo -e "Broadcasting, chain name: ${CYAN}$CHAIN_NAME${NC} ..." && echo
TX=$(casper-client put-deploy \
--chain-name "$CHAIN_NAME" \
--node-address "$API_HOST" \
--secret-key "$OWNER_PRIVATE_KEY" \
--session-path "$BONDING_CONTRACT" \
--payment-amount "$payment_amount" \
--session-arg="public_key:public_key='$PUB_KEY_HEX'" \
--session-arg="amount:u512='$BID_AMOUNT'" \
--session-arg="delegation_rate:u8='$validator_comission'" | jq -r '.result | .deploy_hash')
echo "$TX"