我试图在无法访问 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))
);
在这里完成所有 5 个区块头“时代”的回答,通过坎昆很好:https://ethereum.stackexchange.com/questions/163229/how-to-verify-block-hash-post-merge-block-15- 5米
注意:这使用了提供程序,但如果您愿意,您也可以手动输入必要的数据。模板准确。