> **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.

# Signature.toCompactBytes

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

Encodes a [`Signature.Signature`](/docs/utilities/signature/types#signature) as a 64-byte compact byte representation (`r ++ s`, big-endian, 32 bytes each).

Used for signature inputs that omit the recovery byte (e.g. ECDSA verify).

## Imports

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

## Examples

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

const bytes = Signature.toCompactBytes({
  r: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf',
  s: '0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8',
  yParity: 1
})
// @log: Uint8Array [110, 16, 10, ...] // 64 bytes
```

## Definition

```ts
function toCompactBytes(
  signature: Signature<boolean>,
): Bytes.Bytes
```

## Parameters

### signature

* **Type:** `Signature<boolean>`

The signature to encode.

#### signature.r

* **Type:** `0x${string}`

#### signature.s

* **Type:** `0x${string}`

#### signature.yParity

* **Type:** `numberType`
* **Optional**

## Return Type

The 64-byte compact representation.

`Bytes.Bytes`
