Skip to content

Blobs.sidecarsToVersionedHashes

Transforms a list of Blobs.BlobSidecars to their Blob Versioned Hashes.

Imports

Named
import { Blobs } from 'ox'

Examples

import { Blobs } from 'ox'
 
const blobs = Blobs.from('0xdeadbeef')
const sidecars = Blobs.toSidecars(blobs, { kzg })
const versionedHashes = Blobs.sidecarsToVersionedHashes(sidecars)

Configuring Return Type

It is possible to configure the return type for the Versioned Hashes with the as option.

import { Blobs } from 'viem'
import { kzg } from './kzg'
 
const blobs = Blobs.from('0xdeadbeef')
const sidecars = Blobs.toSidecars(blobs, { kzg })
const versionedHashes = Blobs.sidecarsToVersionedHashes(sidecars, {
  as: 'Bytes', 
})
[Uint8Array [ ... ], Uint8Array [ ... ]]

Versioning Hashes

It is possible to configure the version for the Versioned Hashes with the version option.

import { Blobs } from 'viem'
import { kzg } from './kzg'
 
const blobs = Blobs.from('0xdeadbeef')
const sidecars = Blobs.toSidecars(blobs, { kzg })
const versionedHashes = Blobs.sidecarsToVersionedHashes(sidecars, {
  version: 2, 
})

Definition

function sidecarsToVersionedHashes<sidecars, as>(
  sidecars: sidecars | BlobSidecars,
  options?: sidecarsToVersionedHashes.Options<as>,
): sidecarsToVersionedHashes.ReturnType<as>

Source: src/core/Blobs.ts

Parameters

sidecars

  • Type: sidecars | BlobSidecars

The Blobs.BlobSidecars to transform to Blob Versioned Hashes.

options

  • Type: sidecarsToVersionedHashes.Options<as>
  • Optional

Options.

options.as

  • Type: "Bytes" | "Hex" | as
  • Optional

Return type.

options.version

  • Type: number
  • Optional

Version to tag onto the hashes.

Return Type

The versioned hashes.

sidecarsToVersionedHashes.ReturnType<as>