Skip to content

Instantly share code, notes, and snippets.

@peetzweg
Created November 10, 2023 15:56
Show Gist options
  • Save peetzweg/ffca0298bd1c849a80cdade861ce2240 to your computer and use it in GitHub Desktop.
Save peetzweg/ffca0298bd1c849a80cdade861ce2240 to your computer and use it in GitHub Desktop.
etherscan lookup shell function
# 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