From 97604b92b8efa771c25d806de3ee3f5368147eb1 Mon Sep 17 00:00:00 2001 From: squidbear <379651+czarly@users.noreply.github.com> Date: Mon, 24 Mar 2025 05:09:12 +0100 Subject: [PATCH] fix --- get-block.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/get-block.sh b/get-block.sh index c7143632..93349c28 100755 --- a/get-block.sh +++ b/get-block.sh @@ -1,6 +1,17 @@ #!/bin/bash -request="{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${2:-latest}\",false],\"id\":1}" +is_decimal() { + [[ $1 =~ ^[0-9]+$ ]] +} + +block_input=${2:-latest} + +if is_decimal "$block_input"; then + # Convert decimal to hexadecimal + block_input=$(printf "%x" "$block_input") +fi + +request="{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${block_input}\",false],\"id\":1}" echo "${request}"