Created
November 10, 2023 15:56
-
-
Save peetzweg/ffca0298bd1c849a80cdade861ce2240 to your computer and use it in GitHub Desktop.
etherscan lookup shell function
This file contains hidden or 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
# add this to your shell init code, i.e. .zshrc | |
function etherscan() { | |
url="https://etherscan.io" | |
if [[ -z "$1" ]]; then | |
open $url | |
else | |
case ${#1} in | |
42) # 42 chars => account address | |
open "${url}/address/${1}" | |
;; | |
66) # 66 chars => transaction hash | |
open "${url}/tx/${1}" | |
;; | |
*) | |
# <8 chars => block number | |
if ((${#1} <= 8)); then | |
open "${url}/block/${1}" | |
else | |
echo "Unknown input" | |
fi | |
;; | |
esac | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment