# Blobs.commitmentToVersionedHash

Transform a Commitment to its Blob Versioned Hash.

## Imports

:::code-group
```ts [Named]
import { Blobs } from 'ox'
```

```ts [Entrypoint]
import * as Blobs from 'ox/Blobs'
```
:::

## Examples

```ts twoslash
// @noErrors
import { Blobs } from 'ox'
import { kzg } from './kzg'

const blobs = Blobs.from('0xdeadbeef')
const [commitment] = Blobs.toCommitments(blobs, { kzg })
const versionedHash =
  Blobs.commitmentToVersionedHash(commitment) // [!code focus]
```

### Configuring Return Type

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

```ts twoslash
// @noErrors
import { Blobs } from 'ox'
import { kzg } from './kzg'

const blobs = Blobs.from('0xdeadbeef')
const [commitment] = Blobs.toCommitments(blobs, { kzg })
const versionedHashes = Blobs.commitmentToVersionedHash(
  commitment,
  {
    as: 'Bytes' // [!code focus]
  }
)
// @log: [Uint8Array [ ... ], Uint8Array [ ... ]]
```

### Versioning Hashes

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

```ts twoslash
// @noErrors
import { Blobs } from 'ox'
import { kzg } from './kzg'

const blobs = Blobs.from('0xdeadbeef')
const [commitment] = Blobs.toCommitments(blobs, { kzg })
const versionedHashes = Blobs.commitmentToVersionedHash(
  commitment,
  {
    version: 2 // [!code focus]
  }
)
```

## Definition

```ts
function commitmentToVersionedHash<commitment, as>(
  commitment: commitment | Hex.Hex | Bytes.Bytes,
  options?: commitmentToVersionedHash.Options<as>,
): commitmentToVersionedHash.ReturnType<as>
```

**Source:** [src/core/Blobs.ts](https://github.com/wevm/ox/blob/main/src/core/Blobs.ts#L755)

## Parameters

### commitment

* **Type:** `commitment | Hex.Hex | Bytes.Bytes`

The commitment.

### options

* **Type:** `commitmentToVersionedHash.Options<as>`
* **Optional**

Options.

#### options.as

* **Type:** `"Bytes" | "Hex" | as`
* **Optional**

Return type.

#### options.version

* **Type:** `number`
* **Optional**

Version to tag onto the hash.

## Return Type

The Blob Versioned Hash.

`commitmentToVersionedHash.ReturnType<as>`
