From 8b9042b0e839f3337021fc58bb3850449d0b822c Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 15 Dec 2024 23:39:23 -0800 Subject: [PATCH] Add block number input --- index.html | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index b78c938..4abd590 100644 --- a/index.html +++ b/index.html @@ -141,15 +141,15 @@ height: 0.1px; } - .rpc-input-container { + .inline-input-container { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; } - .rpc-input-container input { - flex: 1 40ch; + .inline-input-container input { + flex-grow: 1; } #selected-file { @@ -287,6 +287,7 @@

For each ENS name in the list, this tool will calculate the name's namehash according to ERC-137.

Then it will prepare a JSON-RPC request to query the multicall3 smart contract, which in turn contains batched calls to the ENS Public Resolver 2 and the Old ENS Public Resolver 2 smart contracts for the hexadecimal addresses.

Finally the tool sends the request to an Ethereum node, which executes the payload and provides a response.

+

Note that the multicall3 smart contract was deployed in block number 14353601, so 14353601 is the oldest block that can be queried.

@@ -315,10 +316,14 @@
Advanced options -
+
+
+ + +
@@ -397,7 +402,11 @@ } // Batch multiple "addr(bytes32)" calls to both "ENS Public Resolver 2" AND "Old ENS Public Resolver 2" using the multicall3 smart contract - async function multicall(rpc, names) { + async function multicall(rpc, names, block) { + if (block !== 'latest') { + block = `0x${block.toString(16)}`; + } + // Construct payload const multiCallPrefix = '0x82ad56cb' + // aggregate3((address,bool,bytes)[]) @@ -435,7 +444,7 @@ to: '0xcA11bde05977b3631167028862bE2a173976CA11', // multicall3 data: multiCallPrefix + multiCallTupleOffsets + multiCallTuples1 }, - 'safe' + block ], id: 'new' }, @@ -447,7 +456,7 @@ to: '0xcA11bde05977b3631167028862bE2a173976CA11', // multicall3 data: multiCallPrefix + multiCallTupleOffsets + multiCallTuples2 }, - 'safe' + block ], id: 'old' }]), @@ -498,6 +507,7 @@ status.textContent = ''; // Clear previous status, if any const formData = new FormData(event.target); + const block = formData.get('block') === '' ? 'latest' : Number(formData.get('block')); const combined = `${formData.get('text')}\n${await formData.get('file').text()}`; // Concatenate textarea and file inputs const parsed = new Set(combined.split('\n').map(c => c.split(',')).flat().map(e => e.trim().toLocaleLowerCase())); // Split on newline or comma, flatten, trim whitespace, lowercase, and de-duplicate const cleaned = [...parsed].filter(name => name.slice(-4) === '.eth'); // Remove anything that does not end in '.eth' @@ -509,7 +519,7 @@ return; } - const multicallResponse = await multicall(formData.get('rpc'), cleaned) + const multicallResponse = await multicall(formData.get('rpc'), cleaned, block) .catch(e => { status.textContent = e; return; -- 2.47.3