# Evm.create

Creates an EVM.

Asynchronous because the engine is WebAssembly and browsers refuse to compile a module this size synchronously on the main thread. The module is compiled once per JavaScript realm; every call afterwards is synchronous.

The specification selects the instruction table, gas schedule, precompiles, and transaction handlers. Choosing among compiled precompile sets or handler registries arrives with the configuration surface; until then the specification determines all of them.

## Imports

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

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

## Examples

```ts twoslash
import { Evm } from 'ox/evm'

const evm = await Evm.create()
```

### Seeding state

```ts twoslash
import { Database, Evm } from 'ox/evm'

const evm = await Evm.create({
  database: Database.fromMemory({
    accounts: {
      '0x0000000000000000000000000000000000000001': {
        balance: 1n
      }
    }
  })
})
```

## Definition

```ts
function create(
  options: create.Options & {
    database: Database.Async;
},
): Promise
```

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

## Parameters

### options

* **Type:** `create.Options & {
    database: Database.Async;
  }`

Constructor components.

#### options.block

* **Type:** `Block`
* **Optional**

Block values opcodes read.

#### options.chainId

* **Type:** `bigint`
* **Optional**

Chain id `CHAINID` reports and transactions are validated against.

The transaction-fields form serializes through envelope types whose chain
id is a number, so past 2^53 only the `serialized` form executes.

#### options.database

* **Type:** `Marked | Database`
* **Optional**

State the EVM reads through.

An empty in-memory database by default, holding no accounts. The engine reads a
missing account as balance and nonce zero, so a transaction that costs
nothing still executes; anything needing funds fails until state is
seeded.

#### options.specId

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

Specification whose rules apply.

## Return Type

An EVM.

`Promise<Evm<true>>`
