# Bytes.fromNumber

Encodes a number value into [`Bytes.Bytes`](/api/Bytes/types#bytes).

## Imports

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

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

## Examples

```ts twoslash
import { Bytes } from 'ox'

const data = Bytes.fromNumber(420)
// @log: Uint8Array([1, 164])
```

```ts twoslash
import { Bytes } from 'ox'

const data = Bytes.fromNumber(420, { size: 4 })
// @log: Uint8Array([0, 0, 1, 164])
```

## Definition

```ts
function fromNumber(
  value: bigint | number,
  options?: fromNumber.Options,
): Uint8Array
```

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

## Parameters

### value

* **Type:** `bigint | number`

Number value to encode.

### options

* **Type:** `fromNumber.Options`
* **Optional**

Encoding options.

## Return Type

Encoded [`Bytes.Bytes`](/api/Bytes/types#bytes).

`Uint8Array`
