-
Notifications
You must be signed in to change notification settings - Fork 0
/
send2exchange.sh
executable file
·36 lines (27 loc) · 1.27 KB
/
send2exchange.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
#!/bin/bash
# Usage: ./send2exchange.sh
# Finds out how much liquid coin is available, rounds to whole number
# If liquid coins are available, continue
# Opens wallet $SEND2_WALLET using key $SEND2_WALLETKEY (Defined by env variables)
# Sends coin to exchange $SEND2_TOACCT (using $SEND2_MEMO) from $SEND2_FRACCT
# Locks wallet
#To setup, need to create a wallet with a key that is tied to the tgtrsfr permission. Add environment variables to /etc/profile.d under the telos_envs.sh file
#FOR TESTING, USE THIS VARIABLE AND UNCOMMENT THE SENDAMT=0
#TRIGGER=50
TRIGGER=5500
AMT=`/ext/telos/cleos get account $SEND2_FRACCT -j | jq '.core_liquid_balance'`
AMTT=${AMT%.*}
COIN=${AMTT:1}
if [ $COIN -gt $TRIGGER ]
then
SENDAMT=`expr $COIN - 500`
echo "Net send is "$SENDAMT
# FOR TESTING ONLY
# SENDAMT=10
/ext/telos/cleos wallet unlock -n $SEND2_WALLET --password $SEND2_WALLETKEY
echo "Balance is $AMT. Coin is $COIN."
/ext/telos/cleos push action eosio.token transfer "{\"from\":\""$SEND2_FRACCT"\" \"to\":\""$SEND2_TOACCT"\" \"quantity\":\""$SENDAMT".0000 TLOS\" \"memo\":\""$SEND2_MEMO"\"}" -p "$SEND2_FRACCT@tgtrsfr"
/ext/telos/cleos wallet lock -n $SEND2_WALLET
else
echo "Liquid balance is less than $TRIGGER. Balance is $AMT. Bye."
fi