Skip to content

Block.toRpc

Converts a Block.Block to an Block.Rpc.

Imports

Named
import { Block } from 'ox'

Examples

import { Block } from 'ox'
 
const block = Block.toRpc({
  // ...
  hash: '0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd',
  number: 19868020n,
  size: 520n
  timestamp: 1662222222n,
  // ...
})
{
// ...
hash: '0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd',
number: '0xec6fc6',
size: '0x208',
timestamp: '0x63198f6f',
// ...
}

Definition

function toRpc<includeTransactions, blockTag>(
  block: Block<includeTransactions, blockTag>,
  _options?: toRpc.Options<includeTransactions, blockTag>,
): Rpc<boolean, blockTag>

Source: src/core/Block.ts

Parameters

block

  • Type: Block<includeTransactions, blockTag>

The Block to convert.

block.baseFeePerGas

  • Type: bigintType
  • Optional

Base fee per gas

block.blobGasUsed

  • Type: bigintType
  • Optional

Total used blob gas by all transactions in this block

block.difficulty

  • Type: bigintType
  • Optional

Difficulty for this block

block.excessBlobGas

  • Type: bigintType
  • Optional

Excess blob gas

block.extraData

  • Type: 0x${string}
  • Optional

"Extra data" field of this block

block.gasLimit

  • Type: bigintType

Maximum gas allowed in this block

block.gasUsed

  • Type: bigintType

Total used gas by all transactions in this block

block.hash

  • Type: blockTag extends "pending" ? null : 0x${string}

Block hash or null if pending

block.logsBloom

  • Type: blockTag extends "pending" ? null : 0x${string}

Logs bloom filter or null if pending

block.miner

  • Type: abitype_Address

Address that received this block’s mining rewards

block.mixHash

  • Type: 0x${string}

Unique identifier for the block.

block.nonce

  • Type: blockTag extends "pending" ? null : 0x${string}

Proof-of-work hash or null if pending

block.number

  • Type: blockTag extends "pending" ? null : bigintType

Block number or null if pending

block.parentBeaconBlockRoot

  • Type: 0x${string}
  • Optional

block.parentHash

  • Type: 0x${string}

Parent block hash

block.receiptsRoot

  • Type: 0x${string}

Root of the this block’s receipts trie

block.sealFields

  • Type: readonly 0x${string}[]
  • Optional

block.sha3Uncles

  • Type: 0x${string}

SHA3 of the uncles data in this block

block.size

  • Type: bigintType

Size of this block in bytes

block.stateRoot

  • Type: 0x${string}

Root of this block’s final state trie

block.timestamp

  • Type: bigintType

Unix timestamp of when this block was collated

block.totalDifficulty

  • Type: bigintType
  • Optional

Total difficulty of the chain until this block

block.transactions

  • Type: includeTransactions extends true ? readonly transaction[] : readonly 0x${string}[]

List of transaction objects or hashes

block.transactionsRoot

  • Type: 0x${string}

Root of this block’s transaction trie

block.uncles

  • Type: readonly 0x${string}[]

List of uncle hashes

block.withdrawals

  • Type: readonly Withdrawal[]
  • Optional

List of withdrawal objects

block.withdrawalsRoot

  • Type: 0x${string}
  • Optional

Root of the this block’s withdrawals trie

Return Type

An RPC Block.

Rpc<boolean, blockTag>