├── config.json.default
├── cleos.sh
├── start.sh
├── claim_reward.sh
├── README.md
├── stop.sh
├── LICENSE
└── bot.sh
/config.json.default:
--------------------------------------------------------------------------------
1 | {
2 | "BP_NAME": "YOUR_PRODUCER_NAME",
3 | "CLAIM_INTERVAL": 86460,
4 | "TELEGRAM_BOT_ID": "123456:YYYYYYYYYYYYYYYYYYYYYYYY",
5 | "TELEGRAM_CHAT_IDS": "51111111 52222222 53333333"
6 | }
--------------------------------------------------------------------------------
/cleos.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | #
4 | # Scrip Created by http://CryptoLions.io
5 | # https://github.com/CryptoLions/scripts/
6 | #
7 | ###############################################################################
8 |
9 | CLEOS="/opt/EOS/bin/bin/cleos"
10 |
11 | WALLETHOST="127.0.0.1"
12 | WALLETPORT="9999"
13 |
14 | NODEHOST="127.0.0.1"
15 | NODEPORT="8888"
16 |
17 | $CLEOS -u http://$NODEHOST:$NODEPORT --wallet-url http://$WALLETHOST:$WALLETPORT "$@"
18 |
--------------------------------------------------------------------------------
/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | #
4 | # Scrip Created by http://CryptoLions.io
5 | # Claim Rewards Bot
6 | #
7 | # Claims each 24h+1min, sends telegram report and saves all into log.
8 | #
9 | # Edit config.json with your data and run start.sh to run bot in background
10 | # !!! Compile claim_reward.sh to claim_reward using shc (readme) or edit line 34
11 | #
12 | # https://github.com/CryptoLions/
13 | #
14 | ################################################################################
15 |
16 | DATADIR="./"
17 |
18 | ./stop.sh
19 | ./bot.sh > $DATADIR/claimbot_out.log 2> $DATADIR/claimbot_err.log & echo $! > $DATADIR/claimbot.pid
20 |
21 |
--------------------------------------------------------------------------------
/claim_reward.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | #
4 | # Scrip Created by http://CryptoLions.io
5 | # Claim Rewards Bot
6 | #
7 | # Claims each 24h+1min, sends telegram report and saves all into log.
8 | #
9 | # Edit config.json with your data and run start.sh to run bot in background
10 | # !!! Compile claim_reward.sh to claim_reward using shc (readme) or edit line 34
11 | #
12 | # https://github.com/CryptoLions/
13 | #
14 | ################################################################################
15 |
16 | ./cleos.sh wallet unlock --password XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > /dev/null 2> /dev/null
17 | ./cleos.sh system claimrewards $1 -p $1 -j
18 | ./cleos.sh wallet lock > /dev/null 2> /dev/null
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # EOS-Claim-Bot
2 | claim rewards bot + Telegram and log report
3 |
4 | 1. Copy config.json.default to config.json and edit with your data (how to create bot and get chat ID check below)
5 | 2. Edit cleos.sh
6 | 3. Edit claim_reward.sh with your wallet password (wallet should have producer key imported)
7 | 4. Compile and obfuscate claim_reward.sh to claim_reward using shc (If you dont have you need to install it somevere https://github.com/neurobin/shc)
8 | ```
9 | shc -U -f claim_reward.sh -o claim_reward
10 | ```
11 | 5. Run start.sh to start bot in background.
12 |
13 | # Telegram Bot and chat_ids
14 | You need to create Telegram bot before: @BotFather
15 | First you need register a bot. You will receive BOT_ID. Open your bot and send first /start
16 | visit url to get user ids:
17 | https://api.telegram.org/botBOT_ID/getUpdates
18 | where BOT_ID is your bot id received on bot registration
19 |
--------------------------------------------------------------------------------
/stop.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | #
4 | # Scrip Created by http://CryptoLions.io
5 | # Claim Rewards Bot
6 | #
7 | # Claims each 24h+1min, sends telegram report and saves all into log.
8 | #
9 | # Edit config.json with your data and run start.sh to run bot in background
10 | # !!! Compile claim_reward.sh to claim_reward using shc (readme) or edit line 34
11 | #
12 | # https://github.com/CryptoLions/
13 | #
14 | ################################################################################
15 |
16 | DIR="./"
17 |
18 |
19 | if [ -f $DIR"/claimbot.pid" ]; then
20 | pid=`cat $DIR"/claimbot.pid"`
21 | echo $pid
22 | kill $pid
23 | rm -r $DIR"/claimbot.pid"
24 |
25 | echo -ne "Stoping Daemon"
26 |
27 | while true; do
28 | [ ! -d "/proc/$pid/fd" ] && break
29 | echo -ne "."
30 | sleep 1
31 | done
32 | echo -ne "\rDaemon Stopped. \n"
33 | fi
34 |
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Cryptolions.io
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/bot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ################################################################################
3 | #
4 | # Scrip Created by http://CryptoLions.io
5 | # Claim Rewards Bot
6 | #
7 | # Claims each 24h+1min, sends telegram report and saves all into log.
8 | #
9 | # Edit config.json with your data and run start.sh to run bot in background
10 | # !!! Compile claim_reward.sh to claim_reward using shc (readme) or edit line 34
11 | #
12 | # https://github.com/CryptoLions/
13 | #
14 | ################################################################################
15 |
16 | config="config.json"
17 | BP_NAME="$( jq -r '.BP_NAME' "$config" )";
18 | CLAIM_INTERVAL="$( jq -r '.CLAIM_INTERVAL' "$config" )";
19 | TELEGRAM_BOT_ID="$( jq -r '.TELEGRAM_BOT_ID' "$config" )";
20 | TELEGRAM_CHAT_IDS=($( jq -r '.TELEGRAM_CHAT_IDS' "$config" ));
21 |
22 | TELEGRAM_API="https://api.telegram.org/bot";
23 | TELEGRAM_SEND_MSG=$TELEGRAM_API$TELEGRAM_BOT_ID"/sendMessage";
24 |
25 | getLastClaim(){
26 | LAST_CLAIM_TIME=$(./cleos.sh system listproducers -l 100 -j | jq -r '.rows[] | select(.owner == "'$BP_NAME'") | .last_claim_time') #'
27 |
28 | LAST_CLAIM_TIME=$(date -d $LAST_CLAIM_TIME +"%s")
29 | return $LAST_CLAIM_TIME
30 | }
31 |
32 |
33 | claim_reward(){
34 | CLAIM=$(./claim_reward $BP_NAME 2>stderr.txt)
35 |
36 | ERR=$(cat stderr.txt)
37 | rm stderr.txt
38 | #CLAIM=$(cat claim)
39 | echo "CLAIN REWARD $(date)" >> log.txt
40 | echo "--stdout-----------------------" >> log.txt
41 | echo $CLAIM >> log.txt
42 | echo "--stderr-----------------------" >> log.txt
43 | echo $ERR >> log.txt
44 | echo "-------------------------" >> log.txt
45 |
46 | if [[ "$ERR" == *"Error"* && "$CLAIM" == "" ]]; then
47 | #claim error
48 | sendmessage "Error on claim. Will try again in 2 min..."
49 | sleep 120
50 | claim_reward "";
51 | return
52 | fi
53 |
54 | TXID=$(echo "${CLAIM}" | jq -r '.transaction_id');
55 | TOTAL=0
56 | OUTPUT="";
57 | for row in $(echo "${CLAIM}" | jq -r '.processed.action_traces[0].inline_traces[] | @base64'); do
58 | _jq() {
59 | echo ${row} | base64 --decode | jq -r ${1}
60 | }
61 | sub_json=$(_jq '.')
62 |
63 | for row in $(echo "${sub_json}" | jq -r '.inline_traces[] | @base64'); do
64 | _jq() {
65 | echo ${row} | base64 --decode | jq -r ${1}
66 | }
67 | receiver=$(_jq '.receipt.receiver')
68 | if [[ "$receiver" == "$BP_NAME" ]]; then
69 | TO=$(_jq '.act.data.to');
70 | QUANTITY=$(_jq '.act.data.quantity');
71 | FROM=$(_jq '.act.data.from');
72 | MEMO=$(_jq '.act.data.memo');
73 |
74 | AMOUNT_A=($QUANTITY)
75 | AMOUNT_=${AMOUNT_A[0]}
76 | AMOUNT=${AMOUNT_//\./}
77 |
78 | #TOTAL=$(echo "$TOTAL+$AMOUNT" | bc)
79 | TOTAL=$(($TOTAL+$AMOUNT))
80 |
81 | #TOTAL=$(($TOTAL+$((${AMOUNT[0]}*1000))));
82 | if [ "$OUTPUT" != "" ]; then
83 | OUTPUT="$OUTPUT----------\n";
84 | fi
85 | OUTPUT="$OUTPUTFrom: $FROM \n";
86 | OUTPUT="$OUTPUTTo: $TO \n";
87 | OUTPUT="$OUTPUTQuantity: $QUANTITY \n";
88 | OUTPUT="$OUTPUTMemo: $MEMO \n";
89 | fi
90 | done
91 |
92 | done
93 |
94 | OUTPUT="💰CLAIM REWARD: $(date) \n TX ID: $TXID \n\n$OUTPUT";
95 | OUTPUT="$OUTPUT================== \n";
96 | OUTPUT="$OUTPUTTotal: $( echo "scale=4; $TOTAL/10000" | bc -l) EOS \n";
97 |
98 |
99 | sendmessage "$OUTPUT"
100 | echo -ne $OUTPUT >> log.txt
101 |
102 | echo "waiting new claim..."
103 | sleep $CLAIM_INTERVAL
104 | claim_reward ""
105 |
106 |
107 | }
108 | sendmessage(){
109 |
110 | msg=$1
111 | for i in "${TELEGRAM_CHAT_IDS[@]}"
112 | do
113 | curl --data chat_id="$i" --data-urlencode "text=$(echo -ne $msg)" "$TELEGRAM_SEND_MSG?parse_mode=html" >/dev/null 2>/dev/null
114 | done
115 | }
116 |
117 |
118 | getLastClaim ""
119 | now=`(date +%s)`
120 |
121 | if [ $(($now-$LAST_CLAIM_TIME)) -lt $CLAIM_INTERVAL ]; then
122 | waitt=$(($CLAIM_INTERVAL - $now + $LAST_CLAIM_TIME));
123 | wait_min=$((waitt/60));
124 | echo "wait to claim: $wait_min min"
125 | sendmessage "⚡️ Claim Bot started. Next Claim in: $wait_min min"
126 | sleep $waitt;
127 | claim_reward ""
128 |
129 | else
130 | echo "It's Time to claimreward."
131 | claim_reward ""
132 | fi
133 |
134 |
--------------------------------------------------------------------------------