# Evm.commitSource

Applies state a caller holds to the EVM.

The counterpart to [`ExecutedTx.detach`](/evm/execution/ExecutedTx/detach): state taken out of an EVM, optionally edited through [`PendingState.insertAccount`](/evm/execution/PendingState/insertAccount), and put back. Later transactions see it.

A transaction's lifecycle markers do not survive the trip. State that was created or self-destructed goes back as plain values, so re-applying it cannot wipe storage the caller meant to keep.

## 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, PendingState } from 'ox/evm'

const { pendingState } = ExecutedTx.detach(Evm.transact(evm, transaction))
Evm.commitSource(evm, pendingState)
```

## Definition

```ts
function commitSource<asynchronous>(
  evm: Evm<asynchronous>,
  state: PendingState.PendingState,
): Awaitable<asynchronous, void>
```

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

## Parameters

### evm

* **Type:** `Evm<asynchronous>`

EVM to apply to.

#### evm.'~async'

* **Type:** `asynchronous`

#### evm.'~chainId'

* **Type:** `bigint`

#### evm.'~config'

* **Type:** `{ block: Block; specId: "frontier" | "homestead" | "tangerine" | "spuriousDragon" | "byzantium" | "petersburg" | "istanbul" | "berlin" | "london" | "merge" | "shanghai" | "cancun" | "prague" | "osaka" | "amsterdam"; version?: Version; }`

The engine's current execution config.

Held so a setter can replace one half without discarding the other, since
the adapter's operation carries both.

#### evm.'~driver'

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

Drives the asynchronous source, when there is one.

#### evm.'~engine'

* **Type:** `Engine`

#### evm.block

* **Type:** `Block`

#### evm.specId

* **Type:** `"frontier" | "homestead" | "tangerine" | "spuriousDragon" | "byzantium" | "petersburg" | "istanbul" | "berlin" | "london" | "merge" | "shanghai" | "cancun" | "prague" | "osaka" | "amsterdam"`

#### evm.version

* **Type:** `Version`
* **Optional**

### state

* **Type:** `PendingState.PendingState`

State to apply.

#### state.'~changes'

* **Type:** `Changes`

## Return Type

`Awaitable<asynchronous, void>`
