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

# TxEnvelopeEip7702.serialize

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

Serializes a [`TxEnvelopeEip7702.TxEnvelopeEip7702`](/docs/utilities/txenvelopeeip7702/types#txenvelopeeip7702).

## Imports

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

## Examples

```ts twoslash
// @noErrors
import {
  Authorization,
  Secp256k1,
  TxEnvelopeEip7702,
  Value
} from 'viem/utils'

const authorization = Authorization.from({
  address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  chainId: 1,
  nonce: 0n
})

const signature = Secp256k1.sign({
  payload: Authorization.getSignPayload(authorization),
  privateKey: '0x...'
})

const authorizationList = [
  Authorization.from(authorization, { signature })
]

const envelope = TxEnvelopeEip7702.from({
  authorizationList,
  chainId: 1,
  maxFeePerGas: Value.fromGwei('10'),
  to: '0x0000000000000000000000000000000000000000',
  value: Value.fromEther('1')
})

const serialized = TxEnvelopeEip7702.serialize(envelope) // [!code focus]
```

### Attaching Signatures

It is possible to attach a `signature` to the serialized Transaction Envelope.

```ts twoslash
// @noErrors
import { Secp256k1, TxEnvelopeEip7702, Value } from 'viem/utils'

const envelope = TxEnvelopeEip7702.from({
  authorizationList: [...],
  chainId: 1,
  maxFeePerGas: Value.fromGwei('10'),
  to: '0x0000000000000000000000000000000000000000',
  value: Value.fromEther('1'),
})

const signature = Secp256k1.sign({
  payload: TxEnvelopeEip7702.getSignPayload(envelope),
  privateKey: '0x...',
})

const serialized = TxEnvelopeEip7702.serialize(envelope, { // [!code focus]
  signature, // [!code focus]
}) // [!code focus]

// ... send `serialized` transaction to JSON-RPC `eth_sendRawTransaction`
```

## Definition

```ts
function serialize(
  envelope: PartialBy<TxEnvelopeEip7702, 'type'>,
  options?: serialize.Options,
): Serialized
```

## Parameters

### envelope

* **Type:** `PartialBy<TxEnvelopeEip7702, 'type'>`

The Transaction Envelope to serialize.

### options

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

Options.

#### options.signature

* **Type:** `{ r: 0x${string}; s: 0x${string}; yParity: number; }`
* **Optional**

Signature to append to the serialized Transaction Envelope.

## Return Type

The serialized Transaction Envelope.

`Serialized`
