2023-06-21 23:25:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2024-04-23 10:45:12 +00:00
|
|
|
geth_endpoint="${1:-$ETH_HTTP_PATH}"
|
2023-06-21 23:25:27 +00:00
|
|
|
|
|
|
|
latest_block_hex=$(curl -s $geth_endpoint -X POST -H "Content-Type: application/json" \
|
|
|
|
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":42}' | \
|
2024-07-24 08:38:09 +00:00
|
|
|
python3 -c 'import json, sys; print(int(json.load(sys.stdin)["result"], 16))' \
|
|
|
|
)
|
2023-06-21 23:25:27 +00:00
|
|
|
|
|
|
|
printf "%d" $latest_block_hex
|