# SignatureEnvelope.serialize

Serializes a signature envelope to a hex-encoded string.

Wire format: - secp256k1: 65 bytes (no type prefix, for backward compatibility) - P256: `0x01` + r (32) + s (32) + pubKeyX (32) + pubKeyY (32) + prehash (1) = 130 bytes - WebAuthn: `0x02` + webauthnData (variable) + r (32) + s (32) + pubKeyX (32) + pubKeyY (32) - Keychain V1: `0x03` + userAddress (20) + inner signature (recursive) - Keychain V2: `0x04` + userAddress (20) + inner signature (recursive)

[Signature Types](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#signature-types)

## Imports

:::code-group
```ts [Named]
import { SignatureEnvelope } from 'ox/tempo'
```

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

## Examples

```ts twoslash
import { SignatureEnvelope } from 'ox/tempo'

const serialized = SignatureEnvelope.serialize({
  signature: {
    r: '0x0000000000000000000000000000000000000000000000000000000000000000',
    s: '0x0000000000000000000000000000000000000000000000000000000000000000',
    yParity: 0
  },
  type: 'secp256k1'
})
```

## Definition

```ts
function serialize(
  envelope: UnionPartialBy<SignatureEnvelope, 'prehash'>,
  options?: serialize.Options,
): Serialized
```

**Source:** [src/tempo/SignatureEnvelope.ts](https://github.com/wevm/ox/blob/main/src/tempo/SignatureEnvelope.ts#L1794)

## Parameters

### envelope

* **Type:** `UnionPartialBy<SignatureEnvelope, 'prehash'>`

The signature envelope to serialize.

### options

* **Type:** `serialize.Options`
* **Optional**

#### options.magic

* **Type:** `boolean`
* **Optional**

Whether to serialize the signature envelope with the Tempo magic identifier.
This is useful for being able to distinguish between Tempo and non-Tempo (e.g. ERC-1271) signatures.

## Return Type

The hex-encoded serialized signature.

`Serialized`
