> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.sqd.dev/feedback

```json
{
  "path": "/en/sdk/pipes-sdk/evm/reference/utility-components/factory",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# factory

> Track dynamically created contracts

Track dynamically created contracts with [evmDecoder()](./evm-decoder).

```ts theme={"system"}
factory(config: FactoryConfig): Factory
```

**Parameters:**

* `address`: Factory contract address or array of addresses (required)
* `event`: Factory creation event ABI or filtered event object (required)

  * **Simple format**: `AbiEvent<T>` - Capture all factory events
  * **Filtered format**: `{ event: AbiEvent<T>, params: {...} }` - Filter by indexed parameters

  Events should be specified using [the same approach as `evmDecoder()` itself uses](../../guides/basic-development/handling-events#specifying-events).
* `parameter`: Extract child address `(event) => string` (required)
* `database`: A [factory store](#contractfactorystore) that persists the list of known child contracts (required)

**Example:**

```ts theme={"system"}
import { factory, contractFactoryStore } from "@subsquid/pipes/evm";

const factoryInstance = factory({
  address: "0x1f98431c8ad98523631ae4a59f267346ea31f984",
  event: factoryAbi.events.PoolCreated,
  parameter: "pool",
  database: contractFactoryStore({ path: "./pools.sqlite" }),
});
```

**Filtered factory events:**

```ts theme={"system"}
factory({
  address: "0x1f98431c8ad98523631ae4a59f267346ea31f984",
  event: {
    event: factoryAbi.events.PoolCreated,
    params: {
      token0: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
    },
  },
  parameter: "pool",
  database: contractFactoryStore({ path: "./weth-pools.sqlite" }),
});
```

<Warning>
  Only **indexed event parameters** can be used in the `params` object. Another way to look at it is that parameter values should be available as event topics. [Reference](https://docs.soliditylang.org/en/latest/contracts.html#events).
</Warning>

## contractFactoryStore

Create an SQLite factory database: an object used to persist the list of child contracts in a fork-aware way. For now, only SQLite-based factory databases are supported.

```ts theme={"system"}
contractFactoryStore(config: { path: string }): FactoryDatabase
```
