]> git.ardis.lu - block-hash-calculator/commitdiff
Make block number field optional
authorArdis Lu <ardisglu@gmail.com>
Sun, 29 Jun 2025 05:46:35 +0000 (22:46 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 29 Jun 2025 05:46:35 +0000 (22:46 -0700)
index.html

index a25ab306f9437f624f927a672e6271363bccacca..acdd32b91ff47a5a5ce69ba999dae253fb0eaed9 100644 (file)
@@ -27,8 +27,8 @@
     <a href="https://github.com/ardislu/block-hash-calculator/">GitHub</a>
     <p>Enter a block number and a JSON-RPC provider below to recalculate the block's hash from its header fields. Known supported networks: Ethereum, Polygon PoS, BNB Chain, OP Mainnet, Base, Arbitrum One, Linea, Scroll, Blast, Mantle, Avalanche C-Chain, ZKsync Era, Ink Mainnet, Sonic Mainnet, Unichain, World Chain, Soneium, Zircuit Mainnet, and Taiko Alethia.</p>
     <form>
-      <label for="num">Block number</label>
-      <input id="num" name="num" type="number" min="0" placeholder="12345678" required>
+      <label for="num">Block number (empty value will default to latest block)</label>
+      <input id="num" name="num" type="number" min="0" placeholder="12345678">
 
       <label for="rpc">JSON-RPC</label>
       <input id="rpc" name="rpc" type="url" placeholder="https://ethereum-rpc.publicnode.com" value="https://ethereum-rpc.publicnode.com" required>
@@ -72,7 +72,7 @@
           jsonrpc: '2.0',
           id: 1,
           method: 'eth_getBlockByNumber',
-          params: [`0x${BigInt(num).toString(16)}`, false]
+          params: [num === '' ? 'latest' : `0x${BigInt(num).toString(16)}`, false]
         })
       }).then(r => r.json()).catch(e => e);
 
This page took 0.03828 seconds and 4 git commands to generate.