UNPKG

@ethereumjs/block

Version:
36 lines 1.28 kB
import { BlockHeader } from './header.js'; import { numberToHex } from './helpers.js'; /** * Creates a new block header object from Ethereum JSON RPC. * * @param blockParams - Ethereum JSON RPC of block (eth_getBlockByNumber) * @param options - An object describing the blockchain */ export function blockHeaderFromRpc(blockParams, options) { const { parentHash, sha3Uncles, miner, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, withdrawalsRoot, blobGasUsed, excessBlobGas, parentBeaconBlockRoot, requestsRoot, } = blockParams; const blockHeader = BlockHeader.fromHeaderData({ parentHash, uncleHash: sha3Uncles, coinbase: miner, stateRoot, transactionsTrie: transactionsRoot, receiptTrie: receiptsRoot, logsBloom, difficulty: numberToHex(difficulty), number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, withdrawalsRoot, blobGasUsed, excessBlobGas, parentBeaconBlockRoot, requestsRoot, }, options); return blockHeader; } //# sourceMappingURL=header-from-rpc.js.map