Skip to content

useBlock

Hook for fetching information about a block at a block number, hash or tag.

Import

import { useBlock } from "@hypergate/react";

Usage

Block:

Hash:

Timestamp:

Parameters

 
import { type UseBlockParameters } from "@hypergate/react";

blockHash

`string`

Information at a given block hash.

index.tsx
 
import { useBlock } from "@hypergate/react";
 
function App() {
  const result = useBlock({
    blockHash:
      "49453CB36AB0F993A3AD6C6A765E7D5F44B5017577850EB66EA644482D0AB8B6", 
  });
}

blockNumber

number | "current" | "closed" | "validated"

Information at a given block number.

index.tsx
 
import { useBlock } from "@hypergate/react";
 
function App() {
  const result = useBlock({
    blockNumber: 42069, 
  });
}

includeTransactions

boolean

Whether or not to include transactions as objects.

index.tsx
 
import { useBlock } from "@hypergate/react";
 
function App() {
  const result = useBlock({
    includeTransactions: true, 
  });
}

Return Type

 
import { type UseBlockReturnType } from "@hypergate/react";