-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathage-check
More file actions
41 lines (41 loc) · 2.1 KB
/
age-check
File metadata and controls
41 lines (41 loc) · 2.1 KB
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
#!/usr/bin/env bash
############################################################################
################ colors ####################################################
restore="\033[00m"
underline="\033[4m"
############################################################################
################ init ######################################################
######### get your own API_KEY at https://www.covalenthq.com/ ##############
export COVALENTHQ_KEY="API_KEY"
export WALLETS="$(sed wallets.txt -e 's/ /\n/g' | sed -e '/^$/d' | tr '[:upper:]' '[:lower:]')"
export SUPPORTED_CHAINS="$(curl -s -X GET https://api.covalenthq.com/v1/chains/? -H 'Content-Type: application/json' -u "${COVALENTHQ_KEY}": \# |\
jq '.data.items[].name')" 2>/dev/null
############################################################################
################ get transactions info #####################################
get_txs(){
link="https://api.covalenthq.com/v1/${2}/address/${1}/transactions_summary/?"
earliest_timestamp="$(curl -s -X GET "${link}" -H 'Content-Type: applicatio1/json' -u "${COVALENTHQ_KEY}": \# | jq '.data.items[].earliest_transaction.block_signed_at' | sed 's/"//g')"
age_days="$(($((`date +"%s"` - `date -d "${earliest_timestamp}" +"%s"`)) / 86400))"
if [ "${age_days}" != "0" ]; then
echo "${age_days}"
else
echo
fi
} 2>/dev/null
############################################################################
################ run query per wallet ######################################
common(){
for wallet in $WALLETS;do
echo -n "${wallet} "
get_txs "${wallet}" "${1}"
done
}
############################################################################
################ check input ###############################################
if $(echo "${SUPPORTED_CHAINS}" | grep -qw "${1}-mainnet"); then
echo "${underline}Age of earliest transaction in days:${restore}"
common "${1}-mainnet"
else
echo "${underline}Supported chains:${restore}"
echo "${SUPPORTED_CHAINS}" | grep "mainnet" | sed -e 's/"//g' -e 's/-mainnet//g'| sort -u
fi