Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance gas price #803

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ Spins up a geth testnet.

dapp-verify-contract -- verify contract source on etherscan
Usage: dapp verify-contract <path>:<contractname> <address> [constructorArgs]

Example: `dapp verify-contract src/auth/authorities/RolesAuthority.sol:RolesAuthority 0x9ed0e..`

Requires `ETHERSCAN_API_KEY` to be set.

Expand Down
46 changes: 45 additions & 1 deletion src/seth/libexec/seth/seth-gas-price
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
#!/usr/bin/env bash
set -e
seth rpc eth_gasPrice

if command -v tput > /dev/null 2>&1; then
if [ $(($(tput colors 2> /dev/null))) -ge 8 ]; then
# Enable colors
TPUT_RESET="$(tput sgr 0)"
TPUT_YELLOW="$(tput setaf 3)"
TPUT_RED="$(tput setaf 1)"
TPUT_BLUE="$(tput setaf 4)"
TPUT_GREEN="$(tput setaf 2)"
TPUT_WHITE="$(tput setaf 7)"
TPUT_BOLD="$(tput bold)"
fi
fi


GASNOW_RESPONSE=$(curl -s https://www.gasnow.org/api/v3/gas/price)
response=$(jq '.code' <<< $GASNOW_RESPONSE)
if [[ $response != "200" ]]; then
echo "Could not get gas information from ${TPUT_BOLD}gasnow.org${TPUT_RESET}: https://www.gasnow.org"
echo "response code: $response"
else
rapid=$(( $(jq '.data.rapid' <<< $GASNOW_RESPONSE) / 1000000000 ))
fast=$(( $(jq '.data.fast' <<< $GASNW_RESPONSE) / 1000000000 ))
standard=$(( $(jq '.data.standard' <<< $GASNOW_RESPONSE) / 1000000000 ))
slow=$(( $(jq '.data.slow' <<< $GASNOW_RESPONSE) / 1000000000 ))
echo "Gas prices from ${TPUT_BOLD}gasnow.org${TPUT_RESET}: https://www.gasnow.org"
echo " \
${TPUT_RED}Rapid: $rapid gwei ${TPUT_RESET}
${TPUT_YELLOW}Fast: $fast gwei
${TPUT_BLUE}Standard: $standard gwei
${TPUT_GREEN}Slow: $slow gwei${TPUT_RESET}" | column -t
fi
PROVIDER_GAS_PRICE=$(( $(seth rpc eth_gasPrice) / 1000000000 ))
if [[ $PROVIDER_GAS_PRICE -ge $rapid ]];then
COLOR=${TPUT_RED}
elif [[ $PROVIDER_GAS_PRICE -ge $fast ]];then
COLOR=${TPUT_YELLOW}
elif [[ $PROVIDER_GAS_PRICE -ge $standard ]];then
COLOR=${TPUT_BLUE}
else
COLOR=${TPUT_GREEN}
fi
echo "Gas price from your RPC endpoint: ${COLOR}${PROVIDER_GAS_PRICE} gwei${TPUT_RESET}"

O