我想使用区块头及其内容来验证 EVM 链区块哈希

问题描述 投票:0回答:1

我试图在无法访问 RPC 的情况下验证块,我使用 blockheader 并尝试使用 blockheader 中的数据生成 blockhash,无法弄清楚它的确切流程。

编写了多个如下脚本,但到目前为止还无法获得精确匹配。

const {
      hash,
      parentHash,
      sha3Uncles,
      miner,
      stateRoot,
      transactionsRoot,
      logsBloom,
      difficulty,
      number,
      gasLimit,
      gasUsed,
      timestamp,
      extraData,
      mixHash,
      nonce,
    } = await web3.eth.getBlock(blockNumber);
 preEncode = [
      parentHash,
      sha3Uncles,
      miner,
      stateRoot,
      transactionsRoot,
      logsBloom,
      web3.utils.toHex(difficulty),
      web3.utils.toHex(number),
      web3.utils.toHex(gasLimit),
      web3.utils.toHex(gasUsed),
      web3.utils.toHex(timestamp),
      extraData,
      mixHash,
      nonce,
    ];
   // getting RLP hash
   let encoded = util.rlp.encode(preEncode);
   // Hashing the RLP output
    const hashedOutput = web3.utils.sha3(
      web3.utils.sha3(util.bufferToHex(encoded))
    );
ethereum blockchain web3js ethers.js go-ethereum
1个回答
0
投票

在这里完成所有 5 个区块头“时代”的回答,通过坎昆很好:https://ethereum.stackexchange.com/questions/163229/how-to-verify-block-hash-post-merge-block-15- 5米

注意:这使用了提供程序,但如果您愿意,您也可以手动输入必要的数据。模板准确。

© www.soinside.com 2019 - 2024. All rights reserved.