Skip to content

blobsToCommitments

Compute commitments from a list of blobs.

Import

import { blobsToCommitments } from 'viem'

Usage

example.ts
import { blobsToCommitments, toBlobs } from 'viem'
import { kzg } from './kzg'
 
const blobs = toBlobs({ data: '0x1234' })
const commitments = blobsToCommitments({ blobs, kzg }) 

Returns

Hex[] | ByteArray[]

List of commitments corresponding to the input blobs.

Parameters

blobs

  • Type: Hex[] | ByteArray[]

List of blobs to transform into commitments.

import { blobsToCommitments, toBlobs } from 'viem'
 
const commitments = blobsToCommitments({ 
  blobs: toBlobs({ data: '0x1234' }), 
  kzg, 
}) 

kzg

  • Type: KZG

KZG implementation. See setupKzg for more information.

import * as kzg from 'c-kzg'
import { blobsToCommitments, setupKzg, toBlobs } from 'viem'
import { mainnetTrustedSetupPath } from 'viem/node'
 
const kzg = setupKzg(cKzg, mainnetTrustedSetupPath) 
 
const commitments = blobsToCommitments({ 
  blobs: toBlobs({ data: '0x1234' }),  
  kzg, 
}) 

to

  • Type: "bytes" | "hex"

The output type.

import { blobsToCommitments, toBlobs } from 'viem'
 
const commitments = blobsToCommitments({ 
  blobs: toBlobs({ data: '0x1234' }),
  kzg, 
  to: 'bytes', 
}) 
 
const commitments: readonly ByteArray[]
commitments