Created
October 5, 2021 10:11
-
-
Save azimin/d1d9e76fbadb441e7d012ae7dad4bdf5 to your computer and use it in GitHub Desktop.
Covert given ETH Gas to USD using current average Gas 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 | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Gas to USD | |
# @raycast.mode compact | |
# Optional parameters: | |
# @raycast.icon images/ethereum-logo.png | |
# @raycast.argument1 { "type": "text", "placeholder": "Gas" } | |
# | |
# @raycast.author Alexander Zimin | |
# @raycast.authorURL http://github.com/azimin | |
# @raycast.description Covert ETH Gas to USD using current avarage Gas price | |
price=$(curl -s https://api.coingecko.com/api/v3/coins/ethereum | python -c "import json, sys; print(json.load(sys.stdin)['market_data']['current_price']['usd'])") | |
gas_price=$(curl -s https://ethgasstation.info/api/ethgasAPI.json? | python -c "import json, sys; print(json.load(sys.stdin)['average'])") | |
value=$1 | |
value=$(echo $value | sed 's/[^0-9]*//g') | |
number=0.000000001 | |
t=$(echo $price*$number*$value*$gas_price/10 | bc) | |
int=${t%.*} | |
float=${t%.2f} | |
printf "\$" | |
printf %.2f $(echo "$t" | bc -l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment