Block
export class Block {
constructor(
public hash: Bytes,
public parentHash: Bytes,
public unclesHash: Bytes,
public author: Address,
public stateRoot: Bytes,
public transactionsRoot: Bytes,
public receiptsRoot: Bytes,
public number: BigInt,
public gasUsed: BigInt,
public gasLimit: BigInt,
public timestamp: BigInt,
public difficulty: BigInt,
public totalDifficulty: BigInt,
public size: BigInt | null,
public baseFeePerGas: BigInt | null,
) {}
}
Fields and Use Cases
hash
- Description: The unique identifier of the block (32 bytes)
- Use Case: Identify and reference specific blocks in the blockchain
parentHash
- Description: The unique identifier(hash) of the previous block also known as the parent block
- Use Case: Maintain blockchain integrity and verify block order
unclesHash
- Description: The unique identifier(hash) of the uncle blocks
- Use Case: Can be used to track network metrics in PoW chains. Less relevant for PoS subgraphs as it’s set to a constant value.
- Note: In PoS, this is set to a constant value
author
- Description: The address of the creator of the block
- Use Case: Tracks miner activity and enables analytics on mining performance or reward distribution
stateRoot
, transactionsRoot
, receiptsRoot
- Description: Root hashes of the state, transaction, and receipt tries respectively
- Use Case: Can be used for advanced verification logic or to track chain state evolution in specialized subgraphs.
number
- Description: Current block number
- Use Case: Essential for temporal ordering, filtering, and pagination in your subgraph queries. Often used in mapping logic to track indexing progress.
gasUsed
- Description: The total gas consumed by transactions in the block
- Use Case: Used to create block-level analytics entities and track network utilization patterns in your subgraph.
gasLimit
- Description: The maximum gas that could be used by transactions in the block
- Use Case: Useful for creating network capacity analytics and tracking protocol parameter changes in your subgraph.
timestamp
- Description: The Unix timestamp of the block’s creation
- Use Case: Critical for time-based queries and analytics. Used to create time-series data and enable temporal filtering in your subgraph.
difficulty
- Description: The difficulty of mining the block.
- Use Case: Identify and reference specific blocks in the blockchain
- Note: In PoS, this value is set to constant
totalDifficulty
- Description: The cumulative difficulty of the chain up to and including this block
- Use Case: Identify and reference specific blocks in the blockchain
- Note: In PoS, this value is set to constant
size
- Description: The size of the block in bytes
- Use Case: Useful for creating block size analytics and tracking network growth metrics in your subgraph.
baseFeePerGas
- Description: The minimum gas fee required for transactions in this block
- Use Case: Essential for tracking gas price dynamics and creating fee-related analytics in post-London fork subgraphs.
Important Notes
difficulty
andnonce
have constant or reduced significance in Proof of Stake (PoS) blockchains compared to Proof of Work (PoW) as mining-based computation no longer determines block creation.baseFeePerGas
were introduced in specific Ethereum upgrades, such as the London Upgrade, and are critical for calculating gas fees and implementing the fee burn mechanismunclesHash
field is relevant in Ethereum’s PoW era, representing the Keccak-256 hash of uncle blocks. It becomes less relevant in PoS Ethereum as uncle rewards are no longer part of the protocol