# TxEnvelopeTempo.serialize

Serializes a [`TxEnvelopeTempo.TxEnvelopeTempo`](/tempo/reference/TxEnvelopeTempo/types#txenvelopetempo).

RLP-encodes the transaction with type prefix `0x76`. For fee sponsorship, use `format: 'feePayer'` to serialize with the fee payer magic `0x78` and the sender address.

[RLP Encoding](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction#rlp-encoding)

## Imports

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

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

## Examples

```ts twoslash
// @noErrors
import { Value } from 'ox'
import { TxEnvelopeTempo } from 'ox/tempo'

const envelope = TxEnvelopeTempo.from({
  chainId: 1,
  calls: [
    {
      data: '0xdeadbeef',
      to: '0x0000000000000000000000000000000000000000'
    }
  ],
  maxFeePerGas: Value.fromGwei('10')
})

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

### Attaching Signatures

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

```ts twoslash
// @noErrors
import { Secp256k1, Value } from 'ox'
import { TxEnvelopeTempo } from 'ox/tempo'

const envelope = TxEnvelopeTempo.from({
  chainId: 1,
  calls: [
    {
      data: '0xdeadbeef',
      to: '0x0000000000000000000000000000000000000000'
    }
  ],
  maxFeePerGas: Value.fromGwei('10')
})

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

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

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

## Definition

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

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

## Parameters

### envelope

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

The Transaction Envelope to serialize.

### options

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

Options.

#### options.feePayerSignature

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

Fee payer signature or the sender to cover the fee of.

* If `Signature.Signature`, then this is the fee payer signature.
* If `null`, then this indicates the envelope is intended to be signed by a fee payer.

#### options.format

* **Type:** `"feePayer"`

Whether to serialize the transaction in the fee payer format.

* If `'feePayer'`, then the transaction will be serialized in the fee payer format.
* If `undefined` (default), then the transaction will be serialized in the normal format.

#### options.sender

* **Type:** `Address.Address | undefined`
* **Optional**

Sender address to cover the fee of.

If not provided and a signature is present, the sender will be
automatically derived from the signature.

#### options.signature

* **Type:** `Value`
* **Optional**

Sender signature to append to the serialized envelope.

## Return Type

The serialized Transaction Envelope.

`Serialized`
