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

# ContractFactory

A **ContractFactory** is used to deploy a Contract to the blockchain.

## Type parameters

| Type parameter         | Value                                               |
| :--------------------- | :-------------------------------------------------- |
| `A` *extends* `any`\[] | `any`\[]                                            |
| `I`                    | [`BaseContract`](/sdk/content/classes/BaseContract) |

## Constructors

### new ContractFactory()

```ts theme={null}
new ContractFactory<A, I>(
   abi, 
   bytecode, 
   runner?, 
IPFSHash?): ContractFactory<A, I>
```

Create a new **ContractFactory** with `abi` and `bytecode`, optionally connected to `runner`.

The `bytecode` may be the `bytecode` property within the standard Solidity JSON output.

#### Parameters

| Parameter   | Type                                                                                                      | Default value |
| :---------- | :-------------------------------------------------------------------------------------------------------- | :------------ |
| `abi`       | [`Interface`](/sdk/content/classes/Interface) \| [`InterfaceAbi`](/sdk/content/type-aliases/InterfaceAbi) | `undefined`   |
| `bytecode`  | [`BytesLike`](/sdk/content/type-aliases/BytesLike) \| \{ `"object"`: `string`; }                          | `undefined`   |
| `runner`?   | `null` \| [`ContractRunner`](/sdk/content/interfaces/ContractRunner)                                      | `undefined`   |
| `IPFSHash`? | `null` \| `string`                                                                                        | `null`        |

#### Returns

[`ContractFactory`](/sdk/content/classes/ContractFactory)\<`A`, `I`>

#### Source

[contract/factory.ts:50](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/contract/factory.ts#L50)

## Properties

| Property    | Modifier   | Type                                                                 | Description                                                  |
| :---------- | :--------- | :------------------------------------------------------------------- | :----------------------------------------------------------- |
| `bytecode`  | `readonly` | `string`                                                             | The Contract deployment bytecode. Often called the initcode. |
| `interface` | `readonly` | [`Interface`](/sdk/content/classes/Interface)                        | The Contract Interface.                                      |
| `runner`    | `readonly` | `null` \| [`ContractRunner`](/sdk/content/interfaces/ContractRunner) | The ContractRunner to deploy the Contract as.                |

## Methods

### connect()

```ts theme={null}
connect(runner): ContractFactory<A, I>
```

Return a new **ContractFactory** with the same ABI and bytecode, but connected to `runner`.

#### Parameters

| Parameter | Type                                                                 | Description               |
| :-------- | :------------------------------------------------------------------- | :------------------------ |
| `runner`  | `null` \| [`ContractRunner`](/sdk/content/interfaces/ContractRunner) | The runner to connect to. |

#### Returns

[`ContractFactory`](/sdk/content/classes/ContractFactory)\<`A`, `I`>

A new ContractFactory.

#### Source

[contract/factory.ts:218](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/contract/factory.ts#L218)

***

### deploy()

```ts theme={null}
deploy(...args): Promise<BaseContract & {
  "deploymentTransaction": ContractTransactionResponse;
} & Omit<I, keyof BaseContract>>
```

Resolves to the Contract deployed by passing `args` into the constructor.

This will resovle to the Contract before it has been deployed to the network, so the
[baseContract.waitForDeployment](../classes/BaseContract#waitForDeployment) should be used before sending any
transactions to it.

#### Parameters

| Parameter | Type                       | Description                       |
| :-------- | :------------------------- | :-------------------------------- |
| ...`args` | `ContractMethodArgs`\<`A`> | The arguments to the constructor. |

#### Returns

`Promise`\<[`BaseContract`](/sdk/content/classes/BaseContract) & \{
`"deploymentTransaction"`: [`ContractTransactionResponse`](/sdk/content/classes/ContractTransactionResponse);
} & `Omit`\<`I`, keyof [`BaseContract`](/sdk/content/classes/BaseContract)>>

A promise resolving to the Contract.

#### Source

[contract/factory.ts:126](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/contract/factory.ts#L126)

***

### getDeployTransaction()

```ts theme={null}
getDeployTransaction(...args): Promise<ContractDeployTransaction>
```

Resolves to the transaction to deploy the contract, passing `args` into the constructor.

#### Parameters

| Parameter | Type                       | Description                       |
| :-------- | :------------------------- | :-------------------------------- |
| ...`args` | `ContractMethodArgs`\<`A`> | The arguments to the constructor. |

#### Returns

`Promise`\<[`ContractDeployTransaction`](/sdk/content/interfaces/ContractDeployTransaction)>

A promise resolving to the deployment transaction.

#### Source

[contract/factory.ts:89](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/contract/factory.ts#L89)

***

### fromSolidity()

```ts theme={null}
static fromSolidity<A, I>(output, runner?): ContractFactory<A, I>
```

Create a new **ContractFactory** from the standard Solidity JSON output.

#### Type parameters

| Type parameter         | Value                                                            |
| :--------------------- | :--------------------------------------------------------------- |
| `A` *extends* `any`\[] | `any`\[]                                                         |
| `I`                    | [`ContractInterface`](/sdk/content/interfaces/ContractInterface) |

#### Parameters

| Parameter | Type                                                       | Description               |
| :-------- | :--------------------------------------------------------- | :------------------------ |
| `output`  | `any`                                                      | The Solidity JSON output. |
| `runner`? | [`ContractRunner`](/sdk/content/interfaces/ContractRunner) | The runner to connect to. |

#### Returns

[`ContractFactory`](/sdk/content/classes/ContractFactory)\<`A`, `I`>

A new ContractFactory.

#### Source

[contract/factory.ts:229](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/contract/factory.ts#L229)
