Class Block

Represents a block in the blockchain containing metadata, transactions, and proof. A block includes information like the hash, height, parent block, transactions, and more.

Hierarchy

  • Block

Constructors

  • Constructs a new Block instance.

    Parameters

    • hash: Hash

      The unique hash of the block.

    • height: number

      The height of the block in the blockchain.

    • stateRootHash: Hash

      The hash of the state root for the block.

    • lastSwitchBlockHash: null | Hash

      The hash of the block that switched the state, if available.

    • parentHash: Hash

      The hash of the parent block.

    • eraID: number

      The era ID in which the block was created.

    • timestamp: Timestamp

      The timestamp of the block creation.

    • accumulatedSeed: undefined | Hash

      The accumulated seed for randomness in the block.

    • randomBit: boolean

      A random bit used for consensus.

    • currentGasPrice: number

      The current gas price for transactions in the block.

    • proposer: Proposer

      The proposer of the block.

    • protocolVersion: undefined | string

      The protocol version of the block.

    • eraEnd: undefined | EraEnd

      The era end details for the block's era, if available.

    • transactions: BlockTransaction[]

      The list of transactions included in the block.

    • rewardedSignatures: number[][]

      The list of rewarded signatures.

    • proofs: Proof[]

      The list of proofs associated with the block.

    • Optional originBlockV1: BlockV1

      The origin block in V1 format, if available.

    • Optional originBlockV2: BlockV2

      The origin block in V2 format, if available.

    Returns Block

Properties

accumulatedSeed?: Hash

The accumulated seed for randomness in the block generation.

currentGasPrice: number

The current gas price for transactions included in the block.

eraEnd?: EraEnd

The era end details, if available, for the block's era.

eraID: number

The era ID in which this block was created.

hash: Hash

The unique hash of the block.

height: number

The height of the block in the blockchain.

lastSwitchBlockHash: null | Hash

The hash of the block that switched the current state, if available. This can be null if not applicable.

originBlockV1?: BlockV1

The origin block in V1 format, if available.

originBlockV2?: BlockV2

The origin block in V2 format, if available.

parentHash: Hash

The hash of the parent block in the blockchain.

proofs: Proof[]

A list of proofs associated with this block.

proposer: Proposer

The proposer who created this block.

protocolVersion?: string

The protocol version used for this block.

randomBit: boolean

A random bit used for proof-of-stake consensus.

rewardedSignatures: number[][]

A list of signature IDs that were rewarded in this block.

stateRootHash: Hash

The hash of the state root associated with the block.

timestamp: Timestamp

The timestamp indicating when the block was created.

transactions: BlockTransaction[]

The list of transactions included in this block.

Methods

  • Retrieves the V1 format of the origin block, if available.

    Returns

    The origin block in V1 format, or undefined if not available.

    Returns undefined | BlockV1

  • Retrieves the V2 format of the origin block, if available.

    Returns

    The origin block in V2 format, or undefined if not available.

    Returns undefined | BlockV2

  • Creates a new Block instance from a V1 block format.

    Returns

    A new Block instance created from the provided V1 block format.

    Parameters

    • blockV1: BlockV1

      The V1 block format.

    Returns Block

  • Creates a new Block instance from a BlockWrapper object, which may contain either V1 or V2 block format.

    Returns

    A new Block instance based on the provided blockWrapper and proofs.

    Throws

    Will throw an error if the blockWrapper does not contain a valid blockV1 or blockV2.

    Parameters

    • blockWrapper: BlockWrapper

      The BlockWrapper containing either blockV1 or blockV2.

    • proofs: Proof[]

      The list of proofs associated with the block.

    Returns Block

Generated using TypeDoc