# TxEnvelopeTempo.from

Converts an arbitrary transaction object into a Tempo Transaction Envelope.

Use this to create transaction envelopes with Tempo-specific features like batched calls, fee tokens, access keys, and scheduled execution. Attach a signature using the `signature` option after signing with [`TxEnvelopeTempo.getSignPayload`](/tempo/reference/TxEnvelopeTempo/getSignPayload).

[Tempo Transaction Specification](https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction)

## Imports

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

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

## Examples

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

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

### Attaching Signatures

It is possible to attach a `signature` to the 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'),
  maxPriorityFeePerGas: Value.fromGwei('1')
})

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

const envelope_signed = TxEnvelopeTempo.from(envelope, {
  // [!code focus]
  signature // [!code focus]
}) // [!code focus]
// @log: {
// @log:   chainId: 1,
// @log:   calls: [{ to: '0x0000000000000000000000000000000000000000', value: 1000000000000000000n }],
// @log:   maxFeePerGas: 10000000000n,
// @log:   maxPriorityFeePerGas: 1000000000n,
// @log:   type: 'tempo',
// @log:   r: 125...n,
// @log:   s: 642...n,
// @log:   yParity: 0,
// @log: }
```

### From Serialized

It is possible to instantiate a Tempo Transaction Envelope from a [`TxEnvelopeTempo.Serialized`](/tempo/reference/TxEnvelopeTempo/types#serialized) value.

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

const envelope = TxEnvelopeTempo.from(
  '0x76f84a0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0808080'
)
// @log: {
// @log:   chainId: 1,
// @log:   calls: [{
// @log:     data: '0xdeadbeef',
// @log:     to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
// @log:   }],
// @log:   maxFeePerGas: 10000000000n,
// @log:   type: 'tempo',
// @log: }
```

## Definition

```ts
function from<envelope, signature>(
  envelope: envelope | UnionPartialBy<Input, 'type'> | Serialized,
  options?: from.Options<signature>,
): from.ReturnValue<envelope, signature>
```

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

## Parameters

### envelope

* **Type:** `envelope | UnionPartialBy<Input, 'type'> | Serialized`

The transaction object to convert.

### options

* **Type:** `from.Options<signature>`
* **Optional**

Options.

#### options.feePayerSignature

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

#### options.signature

* **Type:** `signature | Value`
* **Optional**

## Return Type

A Tempo Transaction Envelope.

`from.ReturnValue<envelope, signature>`
