> ## 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.

# Contract

A [**BaseContract**](https://docs.qu.ai/sdk/content/classes/BaseContract.md) with no type guards on its methods or events.

## Extends

* [`BaseContract`](https://docs.qu.ai/sdk/content/classes/BaseContract)\<`this`> & `Omit`\<[`ContractInterface`](https://docs.qu.ai/sdk/content/interfaces/ContractInterface), keyof [`BaseContract`](https://docs.qu.ai/sdk/content/classes/BaseContract)>

## Properties

| Property | Modifier | Type | Description | Inherited from |
| :- | :- | :- | :- | :- |
| `fallback` | `readonly` | `null` \| [`WrappedFallback`](https://docs.qu.ai/sdk/content/interfaces/WrappedFallback) | The fallback or receive function if any. | `_ContractBase().fallback` |
| `filters` | `readonly` | `Record`\<`string`, [`ContractEvent`](https://docs.qu.ai/sdk/content/interfaces/ContractEvent)\<`any`\[]>> | All the Events available on this contract. | `_ContractBase().filters` |
| `interface` | `readonly` | [`Interface`](https://docs.qu.ai/sdk/content/classes/Interface) | The contract Interface. | `_ContractBase().interface` |
| `runner` | `readonly` | `null` \| [`ContractRunner`](https://docs.qu.ai/sdk/content/interfaces/ContractRunner) | The connected runner. This is generally a [**Provider**](https://docs.qu.ai/sdk/content/interfaces/Provider.md) or a [**Signer**](https://docs.qu.ai/sdk/content/interfaces/Signer.md), which dictates what operations are supported. For example, a **Contract** connected to a [**Provider**](https://docs.qu.ai/sdk/content/interfaces/Provider.md) may only execute read-only operations. | `_ContractBase().runner` |
| `target` | `readonly` | `string` \| [`Addressable`](https://docs.qu.ai/sdk/content/interfaces/Addressable) | The target to connect to. This can be an address or any [Addressable](https://docs.qu.ai/sdk/content/interfaces/Addressable.md), such as another contract. To get the resolved address, use the `getAddress` method. | `_ContractBase().target` |

## Methods

### addListener()

```ts theme={null}
addListener(event, listener): Promise<Contract>
```

Alias for [**on**](https://docs.qu.ai/sdk/content/classes/BaseContract.md#on).

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to listen for. |
| `listener` | [`Listener`](https://docs.qu.ai/sdk/content/type-aliases/Listener) | The listener to call when the event is emitted. |

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

#### Inherited from

`_ContractBase().addListener`

#### Source

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

***

### attach()

```ts theme={null}
attach(target): BaseContract
```

Return a new Contract instance with the same ABI and runner, but a different `target`.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `target` | `string` \| [`Addressable`](https://docs.qu.ai/sdk/content/interfaces/Addressable) | The target to connect to. |

#### Returns

[`BaseContract`](https://docs.qu.ai/sdk/content/classes/BaseContract)

The new contract instance.

#### Inherited from

`_ContractBase().attach`

#### Source

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

***

### connect()

```ts theme={null}
connect(runner): BaseContract
```

Return a new Contract instance with the same target and ABI, but a different `runner`.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `runner` | `null` \| [`ContractRunner`](https://docs.qu.ai/sdk/content/interfaces/ContractRunner) | The runner to use. |

#### Returns

[`BaseContract`](https://docs.qu.ai/sdk/content/classes/BaseContract)

The new contract instance.

#### Inherited from

`_ContractBase().connect`

#### Source

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

***

### deploymentTransaction()

```ts theme={null}
deploymentTransaction(): null | ContractTransactionResponse
```

Return the transaction used to deploy this contract.

This is only available if this instance was returned from a [**ContractFactor**](https://docs.qu.ai/sdk/content/classes/ContractFactory.md).

#### Returns

`null` | [`ContractTransactionResponse`](https://docs.qu.ai/sdk/content/classes/ContractTransactionResponse)

The transaction used to deploy this contract or `null`.

#### Inherited from

`_ContractBase().deploymentTransaction`

#### Source

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

***

### emit()

```ts theme={null}
emit(event, ...args): Promise<boolean>
```

Emit an `event` calling all listeners with `args`.

Resolves to `true` if any listeners were called.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to emit. |
| ...`args` | `any`\[] | The arguments to pass to the listeners. |

#### Returns

`Promise`\<`boolean`>

`true` if any listeners were called.

#### Inherited from

`_ContractBase().emit`

#### Source

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

***

### getAddress()

```ts theme={null}
getAddress(): Promise<string>
```

Return the resolved address of this Contract.

#### Returns

`Promise`\<`string`>

The resolved address.

#### Inherited from

`_ContractBase().getAddress`

#### Source

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

***

### getDeployedCode()

```ts theme={null}
getDeployedCode(): Promise<null | string>
```

Return the deployed bytecode or null if no bytecode is found.

#### Returns

`Promise`\<`null` | `string`>

The deployed bytecode or null.

#### Inherited from

`_ContractBase().getDeployedCode`

#### Throws

If the runner does not support .provider.

#### Source

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

***

### getEvent()

```ts theme={null}
getEvent(key): ContractEvent<any[]>
```

Return the event for a given name. This is useful when a contract event name conflicts with a JavaScript name
such as `prototype` or when using a Contract programatically.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `key` | `string` \| [`EventFragment`](https://docs.qu.ai/sdk/content/classes/EventFragment) | The name of the event to return. |

#### Returns

[`ContractEvent`](https://docs.qu.ai/sdk/content/interfaces/ContractEvent)\<`any`\[]>

The event for the given name.

#### Inherited from

`_ContractBase().getEvent`

#### Source

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

***

### getFunction()

```ts theme={null}
getFunction<T>(key): T
```

Return the function for a given name. This is useful when a contract method name conflicts with a JavaScript name
such as `prototype` or when using a Contract programatically.

#### Type parameters

| Type parameter | Value |
| :- | :- |
| `T` *extends* [`ContractMethod`](https://docs.qu.ai/sdk/content/interfaces/ContractMethod)\<`any`\[], `any`, `any`, `T`> | [`ContractMethod`](https://docs.qu.ai/sdk/content/interfaces/ContractMethod)\<`any`\[], `any`, `any`> |

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `key` | `string` \| [`FunctionFragment`](https://docs.qu.ai/sdk/content/classes/FunctionFragment) | The name of the function to return. |

#### Returns

`T`

The function for the given name.

#### Inherited from

`_ContractBase().getFunction`

#### Source

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

***

### listenerCount()

```ts theme={null}
listenerCount(event?): Promise<number>
```

Resolves to the number of listeners of `event` or the total number of listeners if unspecified.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event`? | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to count listeners for. |

#### Returns

`Promise`\<`number`>

The number of listeners.

#### Inherited from

`_ContractBase().listenerCount`

#### Source

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

***

### listeners()

```ts theme={null}
listeners(event?): Promise<Listener[]>
```

Resolves to the listeners subscribed to `event` or all listeners if unspecified.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event`? | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to get listeners for. |

#### Returns

`Promise`\<[`Listener`](https://docs.qu.ai/sdk/content/type-aliases/Listener)\[]>

The listeners.

#### Inherited from

`_ContractBase().listeners`

#### Source

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

***

### off()

```ts theme={null}
off(event, listener?): Promise<Contract>
```

Remove the `listener` from the listeners for `event` or remove all listeners if unspecified.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to remove the listener from. |
| `listener`? | [`Listener`](https://docs.qu.ai/sdk/content/type-aliases/Listener) | The listener to remove. |

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

This contract instance.

#### Inherited from

`_ContractBase().off`

#### Source

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

***

### on()

```ts theme={null}
on(event, listener): Promise<Contract>
```

Add an event `listener` for the `event`.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to listen for. |
| `listener` | [`Listener`](https://docs.qu.ai/sdk/content/type-aliases/Listener) | The listener to call when the event is emitted. |

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

This contract instance.

#### Inherited from

`_ContractBase().on`

#### Source

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

***

### once()

```ts theme={null}
once(event, listener): Promise<Contract>
```

Add an event `listener` for the `event`, but remove the listener after it is fired once.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to listen for. |
| `listener` | [`Listener`](https://docs.qu.ai/sdk/content/type-aliases/Listener) | The listener to call when the event is emitted. |

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

#### Inherited from

`_ContractBase().once`

#### Source

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

***

### queryFilter()

```ts theme={null}
queryFilter(
   event, 
   fromBlock?, 
toBlock?): Promise<(EventLog | Log)[]>
```

Provide historic access to event data for `event` in the range `fromBlock` (default: `0`) to `toBlock` (default:
`"latest"`) inclusive.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to query. |
| `fromBlock`? | [`BlockTag`](https://docs.qu.ai/sdk/content/type-aliases/BlockTag) | The block to start querying from. |
| `toBlock`? | [`BlockTag`](https://docs.qu.ai/sdk/content/type-aliases/BlockTag) | The block to stop querying at. |

#### Returns

`Promise`\<([`EventLog`](https://docs.qu.ai/sdk/content/classes/EventLog) | [`Log`](https://docs.qu.ai/sdk/content/classes/Log))\[]>

An array of event logs.

#### Inherited from

`_ContractBase().queryFilter`

#### Source

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

***

### removeAllListeners()

```ts theme={null}
removeAllListeners(event?): Promise<Contract>
```

Remove all the listeners for `event` or remove all listeners if unspecified.

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event`? | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to remove the listeners from. |

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

This contract instance.

#### Inherited from

`_ContractBase().removeAllListeners`

#### Source

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

***

### removeListener()

```ts theme={null}
removeListener(event, listener): Promise<Contract>
```

Alias for [**off**](https://docs.qu.ai/sdk/content/classes/BaseContract.md#off).

#### Parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `event` | [`ContractEventName`](https://docs.qu.ai/sdk/content/type-aliases/ContractEventName) | The event to remove the listener from. |
| `listener` | [`Listener`](https://docs.qu.ai/sdk/content/type-aliases/Listener) | The listener to remove. |

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

#### Inherited from

`_ContractBase().removeListener`

#### Source

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

***

### waitForDeployment()

```ts theme={null}
waitForDeployment(): Promise<Contract>
```

Resolve to this Contract once the bytecode has been deployed, or resolve immediately if already deployed.

#### Returns

`Promise`\<[`Contract`](https://docs.qu.ai/sdk/content/classes/Contract)>

The contract instance.

#### Inherited from

`_ContractBase().waitForDeployment`

#### Throws

If the contract runner does not support .provider.

#### Source

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.