> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Bytes.random

:::info
`Bytes.random` is a re-export of ox's [`Bytes.random`](https://oxlib.sh/api/Bytes/random). Refer to the ox documentation for the full reference.
:::

Generates random [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) of the specified length.

## Imports

```ts
import { Bytes } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Bytes } from 'viem/utils'

const bytes = Bytes.random(32)
// @log: Uint8Array([... x32])
```

## Definition

```ts
function random(
  length: number,
): Bytes
```

## Parameters

### length

* **Type:** `number`

Length of the random [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) to generate.

## Return Type

Random [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) of the specified length.

`Bytes`
