Skip to content

Blobs.commitmentsToVersionedHashes

Transform a list of Commitments to Blob Versioned Hashes.

Imports

Named
import { Blobs } from 'ox'

Examples

import { Blobs } from 'viem'
import { kzg } from './kzg'
 
const blobs = Blobs.from('0xdeadbeef')
const commitments = Blobs.toCommitments(blobs, { kzg })
const versionedHashes = Blobs.commitmentsToVersionedHashes(commitments)
['0x...', '0x...']

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 commitments = Blobs.toCommitments(blobs, { kzg })
const versionedHashes = Blobs.commitmentsToVersionedHashes(commitments, {
  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 commitments = Blobs.toCommitments(blobs, { kzg })
const versionedHashes = Blobs.commitmentsToVersionedHashes(commitments, {
  version: 2, 
})

Definition

function commitmentsToVersionedHashes<commitments, as>(
  commitments: commitments | readonly Bytes.Bytes[] | readonly Hex.Hex[],
  options?: commitmentsToVersionedHashes.Options<as>,
): commitmentsToVersionedHashes.ReturnType<as>

Source: src/Blobs.ts

Parameters

commitments

  • Type: commitments | readonly Bytes.Bytes[] | readonly Hex.Hex[]

A list of commitments.

options

  • Type: commitmentsToVersionedHashes.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

A list of Blob Versioned Hashes.

commitmentsToVersionedHashes.ReturnType<as>