# TxEnvelopeEip4844.serialize

Serializes a [`TxEnvelopeEip4844.TxEnvelopeEip4844`](/api/TxEnvelopeEip4844/types#txenvelopeeip4844).

## Imports

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

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

## Examples

```ts twoslash
// @noErrors
import { Blobs, TxEnvelopeEip4844 } from 'ox'
import { kzg } from './kzg'

const blobs = Blobs.from('0xdeadbeef')
const blobVersionedHashes = Blobs.toVersionedHashes(blobs, {
  kzg
})

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

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

### Attaching Signatures

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

```ts twoslash
// @noErrors
import {
  Blobs,
  Secp256k1,
  TxEnvelopeEip4844,
  Value
} from 'ox'
import { kzg } from './kzg'

const blobs = Blobs.from('0xdeadbeef')
const blobVersionedHashes = Blobs.toVersionedHashes(blobs, {
  kzg
})

const envelope = TxEnvelopeEip4844.from({
  blobVersionedHashes,
  chainId: 1,
  maxFeePerBlobGas: Value.fromGwei('3'),
  maxFeePerGas: Value.fromGwei('10'),
  maxPriorityFeePerGas: Value.fromGwei('1'),
  to: '0x0000000000000000000000000000000000000000',
  value: Value.fromEther('1')
})

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

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

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

## Definition

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

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

## Parameters

### envelope

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

The Transaction Envelope to serialize.

### options

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

Options.

#### options.sidecars

* **Type:** `Sidecars`
* **Optional**

PeerDAS sidecars to append, producing the 5-element network wrapper.

#### 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`
