# Evm.transact

Executes a transaction and leaves its state changes pending.

The counterpart to [`Evm.callTx`](/evm/execution/Evm/callTx): instead of discarding what the transaction wrote, this hands back a handle that decides. The EVM is held until that handle is committed, discarded, or detached, so only one transaction is outstanding at a time.

A revert or an exceptional halt is a successful execution returning `status: false`, and still produces a handle to resolve.

## Imports

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

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

## Examples

```ts twoslash
// @noErrors
import { Evm, ExecutedTx } from 'ox/evm'

// `using` discards on scope exit, so an early return cannot leave the EVM held.
using executed = Evm.transact(evm, {
  from: '0x0000000000000000000000000000000000000001',
  gas: 100_000n,
  to: '0x0000000000000000000000000000000000000002',
  value: 1n
})

if (ExecutedTx.result(executed).status)
  ExecutedTx.commit(executed)
```

## Definition

```ts
function transact(
  evm: Evm<true>,
  transaction: Ethereum.Tx,
): ExecutedTx.ExecutedTx
```

**Source:** [src/evm/Evm.ts](https://github.com/wevm/ox/blob/main/src/evm/Evm.ts#L350)

## Parameters

### evm

* **Type:** `Evm<true>`

EVM to execute on.

#### evm.'~async'

* **Type:** `asynchronous`

#### evm.'~chainId'

* **Type:** `bigint`

#### evm.'~driver'

* **Type:** `asynchronous extends true ? Driver : undefined`

Drives the asynchronous source, when there is one.

#### evm.'~engine'

* **Type:** `Engine`

### transaction

* **Type:** `Ethereum.Tx`

Transaction and the account it executes as.

#### transaction.accessList

* **Type:** `readonly { address: abitype_Address; storageKeys: readonly 0x${string}[]; }[]`
* **Optional**

EIP-2930 Access List.

#### transaction.authorizationList

* **Type:** `readonly { address: abitype_Address; chainId: numberType; nonce: bigintType; r: 0x${string}; s: 0x${string}; yParity: numberType; }[]`

EIP-7702 Authorization List.

#### transaction.blobVersionedHashes

* **Type:** `readonly 0x${string}[]`

Versioned hashes of blobs to be included in the transaction.

#### transaction.chainId

* **Type:** `numberType`

EIP-155 Chain ID.

#### transaction.data

* **Type:** `0x${string}`
* **Optional**

Contract code or a hashed method call with encoded args

#### transaction.from

* **Type:** `abitype_Address`

Account the transaction executes as.

#### transaction.gas

* **Type:** `bigintType`
* **Optional**

Gas provided for transaction execution

#### transaction.gasPrice

* **Type:** `bigintType`
* **Optional**

Base fee per gas.

#### transaction.input

* **Type:** `0x${string}`
* **Optional**

#### transaction.maxFeePerBlobGas

* **Type:** `bigintType`
* **Optional**

Maximum total fee per gas sender is willing to pay for blob gas (in wei).

#### transaction.maxFeePerGas

* **Type:** `bigintType`
* **Optional**

Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas).

#### transaction.maxPriorityFeePerGas

* **Type:** `bigintType`
* **Optional**

Max priority fee per gas (in wei).

#### transaction.nonce

* **Type:** `bigintType`
* **Optional**

Unique number identifying this transaction

#### transaction.r

* **Type:** `0x${string}`

#### transaction.s

* **Type:** `0x${string}`

#### transaction.serialized

* **Type:** `0x${string} | Uint8Array`

EIP-2718 encoded transaction.

#### transaction.sidecars

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

PeerDAS (EIP-7594) sidecars associated with this transaction. When
defined, the envelope serializes into the 5-element "PooledTransactions"
network wrapper (`rlp([tx_body, wrapper_version, blobs, commitments,
cell_proofs])`).

#### transaction.to

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

Transaction recipient

#### transaction.type

* **Type:** `type`

Transaction type

#### transaction.v

* **Type:** `numberType`
* **Optional**

#### transaction.value

* **Type:** `bigintType`
* **Optional**

Value in wei sent with this transaction

#### transaction.yParity

* **Type:** `numberType`
* **Optional**

ECDSA signature yParity.

## Return Type

A handle over the executed transaction.

`Promise<ExecutedTx.ExecutedTx>`
