Blocks and headers
BlockHeader and Block parse the 80-byte header and full serialised blocks, for example those returned by a
node’s getblockheader and getblock RPCs with verbosity 0. The examples use the genesis block. For what the
header fields mean, see the guide’s Proof-of-work page.
A block header
Section titled “A block header”final header = BlockHeader.fromHex(genesisHeaderHex); // 80 bytes, hex
header.id; // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26fheader.version; // 1header.time; // 1231006505 (seconds since the epoch)header.bits; // 486604799: the encoded difficulty targetheader.nonce; // 2083236893header.hasValidProofOfWork(); // true: the hash is below the targetheader.getDifficulty(); // 1.0header.id is the block hash, in the byte order that block explorers show.
A full block
Section titled “A full block”final block = Block.fromHex(genesisBlockHex);
block.header!.time; // 1231006505block.transactions!.length; // 1block.transactions![0].isCoinbase(); // trueblock.transactions![0].outputs[0].satoshis; // 5000000000: the 50 BTC block rewardblock.validMerkleRoot(); // true: the Transactions match the header's merkle rootvalidMerkleRoot() recomputes the merkle root from the block’s Transactions, and compares it with the one in the
header. MerkleBlock parses the filtered-block format that peers send in reply to Bloom-filtered requests.

