Created
September 1, 2021 23:49
-
-
Save ivandiazwm/04845494dd4bff13b07199e51226ce93 to your computer and use it in GitHub Desktop.
GNOME Widget: ERC-20 token transfer fee price
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Description: GNOME Widget for getting the current fee for transfering ERC-20 tokens in ETH mainnet | |
# Requirement: Use GNOME (in Ubuntu Linux, for example) | |
# Dependency: Install Argos https://github.com/p-e-w/argos | |
# Installation: Add your API keys to this file and copy the file into ~/.config/argos. | |
# Preview: https://ipfs.infura.io:5001/api/v0/cat?arg=QmXbxqwXCzSkQJKdvM6jxkBuKWiSPFc4cMqXMcnDEyxbLy | |
# Author: Ivan Diaz (github.com/ivandiazwm) | |
export PATH="/usr/local/bin:$PATH" | |
DAI_ICON=$(curl -s "https://ipfs.infura.io:5001/api/v0/cat?arg=QmYC2zqVvCQyPg6C7HrmR7oz61FCkZhKhGVuaNv9W2xGVx" | base64 -w 0) | |
# PUT YOUR ETHGASSTATION.INFO API KEY | |
ETHGASSTATION_KEY=""; | |
# PUT YOUR ETHERSCAN.IO API KEY | |
ETHERSCAN_KEY=""; | |
URL=$(echo $ETHGASSTATION_KEY | awk -F '-' '{printf "https://ethgasstation.info/api/ethgasAPI.json?api-key=%s", $1}') | |
URL2=$(echo $ETHERSCAN_KEY | awk -F '-' '{printf "https://api.etherscan.io/api?module=stats&action=ethprice&apikey=%s", $1}') | |
AVG_GAS_PRICE=$(curl -s -X GET $URL | jq -r '"\(.average)"') | |
ETH_PRICE=$(curl -s -X GET $URL2 | jq -r '"\(.result.ethusd)"') | |
RESULT="$AVG_GAS_PRICE,$ETH_PRICE"; | |
# ERC20 TRANSFER GAS IS 65000 | |
ERC20_TRANSFER_PRICE=$(echo $RESULT | awk -F ',' '{printf "$%0.2f\n", 65000*$1*$2/10000000000}'); | |
echo "$ERC20_TRANSFER_PRICE | image='$DAI_ICON' imageWidth=25 imageHeight=10"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment