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

# Interface

An Interface abstracts many of the low-level details for encoding and decoding the data on the blockchain.

An ABI provides information on how to encode data to send to a Contract, how to decode the results and events and how
to interpret revert errors.

The ABI can be specified by [any supported format](/sdk/content/type-aliases/InterfaceAbi).

## Constructors

### new Interface()

```ts theme={null}
new Interface(fragments): Interface
```

Create a new Interface for the fragments.

#### Parameters

| Parameter   | Type                                                     | Description        |
| :---------- | :------------------------------------------------------- | :----------------- |
| `fragments` | [`InterfaceAbi`](/sdk/content/type-aliases/InterfaceAbi) | The ABI fragments. |

#### Returns

[`Interface`](/sdk/content/classes/Interface)

#### Source

[abi/interface.ts:342](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L342)

## Properties

| Property    | Modifier   | Type                                                                  | Description                                                       |
| :---------- | :--------- | :-------------------------------------------------------------------- | :---------------------------------------------------------------- |
| `deploy`    | `readonly` | [`ConstructorFragment`](/sdk/content/classes/ConstructorFragment)     | The Contract constructor.                                         |
| `fallback`  | `readonly` | `null` \| [`FallbackFragment`](/sdk/content/classes/FallbackFragment) | The Fallback method, if any.                                      |
| `fragments` | `readonly` | readonly [`Fragment`](/sdk/content/classes/Fragment)\[]               | All the Contract ABI members (i.e. methods, events, errors, etc). |
| `receive`   | `readonly` | `boolean`                                                             | If receiving ether is supported.                                  |

## Methods

### decodeErrorResult()

```ts theme={null}
decodeErrorResult(fragment, data): Result
```

Decodes the result `data` (e.g. from an `quai_call`) for the specified error (see [**getError**](/sdk/content/classes/Interface#geterror)
for valid values for `key`).

Most developers should prefer the parseCallResult | **parseCallResult** method instead, which will
automatically detect a `CALL_EXCEPTION` and throw the corresponding error.

#### Parameters

| Parameter  | Type                                                              |
| :--------- | :---------------------------------------------------------------- |
| `fragment` | `string` \| [`ErrorFragment`](/sdk/content/classes/ErrorFragment) |
| `data`     | [`BytesLike`](/sdk/content/type-aliases/BytesLike)                |

#### Returns

[`Result`](/sdk/content/classes/Result)

#### Source

[abi/interface.ts:826](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L826)

***

### decodeFunctionData()

```ts theme={null}
decodeFunctionData(fragment, data): Result
```

Decodes the `data` from a transaction `tx.data` for the function specified (see
[**getFunction**](/sdk/content/classes/Interface#getfunction) for valid values for `fragment`).

Most developers should prefer the [**parseTransaction**](/sdk/content/classes/Interface#parsetransaction) method instead, which will
automatically detect the fragment.

#### Parameters

| Parameter  | Type                                                                    |
| :--------- | :---------------------------------------------------------------------- |
| `fragment` | `string` \| [`FunctionFragment`](/sdk/content/classes/FunctionFragment) |
| `data`     | [`BytesLike`](/sdk/content/type-aliases/BytesLike)                      |

#### Returns

[`Result`](/sdk/content/classes/Result)

#### Source

[abi/interface.ts:866](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L866)

***

### decodeFunctionResult()

```ts theme={null}
decodeFunctionResult(fragment, data): Result
```

Decodes the result `data` (e.g. from an `quai_call`) for the specified function (see
[**getFunction**](/sdk/content/classes/Interface#getfunction) for valid values for `key`).

Most developers should prefer the parseCallResult | **parseCallResult** method instead, which will
automatically detect a `CALL_EXCEPTION` and throw the corresponding error.

#### Parameters

| Parameter  | Type                                                                    |
| :--------- | :---------------------------------------------------------------------- |
| `fragment` | `string` \| [`FunctionFragment`](/sdk/content/classes/FunctionFragment) |
| `data`     | [`BytesLike`](/sdk/content/type-aliases/BytesLike)                      |

#### Returns

[`Result`](/sdk/content/classes/Result)

#### Source

[abi/interface.ts:904](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L904)

***

### encodeDeploy()

```ts theme={null}
encodeDeploy(values?): string
```

Encodes a `tx.data` object for deploying the Contract with the `values` as the constructor arguments.

#### Parameters

| Parameter | Type              |
| :-------- | :---------------- |
| `values`? | readonly `any`\[] |

#### Returns

`string`

#### Source

[abi/interface.ts:815](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L815)

***

### encodeErrorResult()

```ts theme={null}
encodeErrorResult(fragment, values?): string
```

Encodes the transaction revert data for a call result that reverted from the the Contract with the sepcified
`error` (see [**getError**](/sdk/content/classes/Interface#geterror) for valid values for `fragment`) with the `values`.

This is generally not used by most developers, unless trying to mock a result from a Contract.

#### Parameters

| Parameter  | Type                                                              |
| :--------- | :---------------------------------------------------------------- |
| `fragment` | `string` \| [`ErrorFragment`](/sdk/content/classes/ErrorFragment) |
| `values`?  | readonly `any`\[]                                                 |

#### Returns

`string`

#### Source

[abi/interface.ts:849](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L849)

***

### encodeFunctionData()

```ts theme={null}
encodeFunctionData(fragment, values?): string
```

Encodes the `tx.data` for a transaction that calls the function specified (see
[**getFunction**](/sdk/content/classes/Interface#getfunction) for valid values for `fragment`) with the `values`.

#### Parameters

| Parameter  | Type                                                                    |
| :--------- | :---------------------------------------------------------------------- |
| `fragment` | `string` \| [`FunctionFragment`](/sdk/content/classes/FunctionFragment) |
| `values`?  | readonly `any`\[]                                                       |

#### Returns

`string`

#### Source

[abi/interface.ts:887](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L887)

***

### encodeFunctionResult()

```ts theme={null}
encodeFunctionResult(fragment, values?): string
```

Encodes the result data (e.g. from an `quai_call`) for the specified function (see
[**getFunction**](/sdk/content/classes/Interface#getfunction) for valid values for `fragment`) with `values`.

This is generally not used by most developers, unless trying to mock a result from a Contract.

#### Parameters

| Parameter  | Type                                                                    |
| :--------- | :---------------------------------------------------------------------- |
| `fragment` | `string` \| [`FunctionFragment`](/sdk/content/classes/FunctionFragment) |
| `values`?  | readonly `any`\[]                                                       |

#### Returns

`string`

#### Source

[abi/interface.ts:975](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L975)

***

### forEachError()

```ts theme={null}
forEachError(callback): void
```

Iterate over all errors, calling `callback`, sorted by their name.

#### Parameters

| Parameter  | Type                        |
| :--------- | :-------------------------- |
| `callback` | (`func`, `index`) => `void` |

#### Returns

`void`

#### Source

[abi/interface.ts:789](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L789)

***

### forEachEvent()

```ts theme={null}
forEachEvent(callback): void
```

Iterate over all events, calling `callback`, sorted by their name.

#### Parameters

| Parameter  | Type                        |
| :--------- | :-------------------------- |
| `callback` | (`func`, `index`) => `void` |

#### Returns

`void`

#### Source

[abi/interface.ts:708](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L708)

***

### forEachFunction()

```ts theme={null}
forEachFunction(callback): void
```

Iterate over all functions, calling `callback`, sorted by their name.

#### Parameters

| Parameter  | Type                        |
| :--------- | :-------------------------- |
| `callback` | (`func`, `index`) => `void` |

#### Returns

`void`

#### Source

[abi/interface.ts:595](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L595)

***

### format()

```ts theme={null}
format(minimal?): string[]
```

Returns the entire Human-Readable ABI, as an array of signatures, optionally as `minimal` strings, which removes
parameter names and unneceesary spaces.

#### Parameters

| Parameter  | Type      |
| :--------- | :-------- |
| `minimal`? | `boolean` |

#### Returns

`string`\[]

#### Source

[abi/interface.ts:438](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L438)

***

### formatJson()

```ts theme={null}
formatJson(): string
```

Return the JSON-encoded ABI. This is the format Solidiy returns.

#### Returns

`string`

#### Source

[abi/interface.ts:447](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L447)

***

### getAbiCoder()

```ts theme={null}
getAbiCoder(): AbiCoder
```

The ABI coder that will be used to encode and decode binary data.

#### Returns

[`AbiCoder`](/sdk/content/classes/AbiCoder)

#### Source

[abi/interface.ts:457](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L457)

***

### getError()

```ts theme={null}
getError(key, values?): null | ErrorFragment
```

Get the [**ErroFragment**](/sdk/content/classes/ErrorFragment) for `key`, which may be an error selector, error name or error
signature that belongs to the ABI.

If `values` is provided, it will use the Typed API to handle ambiguous cases where multiple errors match by name.

If the `key` and `values` do not refine to a single error in the ABI, this will throw.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |
| `values`? | `any`\[] |

#### Returns

`null` | [`ErrorFragment`](/sdk/content/classes/ErrorFragment)

#### Source

[abi/interface.ts:727](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L727)

***

### getEvent()

```ts theme={null}
getEvent(key, values?): null | EventFragment
```

Get the [**EventFragment**](/sdk/content/classes/EventFragment) for `key`, which may be a topic hash, event name or event
signature that belongs to the ABI.

If `values` is provided, it will use the Typed API to handle ambiguous cases where multiple events match by name.

If the `key` and `values` do not refine to a single event in the ABI, this will throw.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |
| `values`? | `any`\[] |

#### Returns

`null` | [`EventFragment`](/sdk/content/classes/EventFragment)

#### Source

[abi/interface.ts:701](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L701)

***

### getEventName()

```ts theme={null}
getEventName(key): string
```

Get the event name for `key`, which may be a topic hash, event name or event signature that belongs to the ABI.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |

#### Returns

`string`

#### Source

[abi/interface.ts:676](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L676)

***

### getFunction()

```ts theme={null}
getFunction(key, values?): null | FunctionFragment
```

Get the [**FunctionFragment**](/sdk/content/classes/FunctionFragment) for `key`, which may be a function selector, function name
or function signature that belongs to the ABI.

If `values` is provided, it will use the Typed API to handle ambiguous cases where multiple functions match by
name.

If the `key` and `values` do not refine to a single function in the ABI, this will throw.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |
| `values`? | `any`\[] |

#### Returns

`null` | [`FunctionFragment`](/sdk/content/classes/FunctionFragment)

#### Source

[abi/interface.ts:588](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L588)

***

### getFunctionName()

```ts theme={null}
getFunctionName(key): string
```

Get the function name for `key`, which may be a function selector, function name or function signature that
belongs to the ABI.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |

#### Returns

`string`

#### Source

[abi/interface.ts:563](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L563)

***

### hasEvent()

```ts theme={null}
hasEvent(key): boolean
```

Returns true if `key` (an event topic hash, event name or event signature) is present in the ABI.

In the case of an event name, the name may be ambiguous, so accessing the
[**EventFragment**](/sdk/content/classes/EventFragment) may require refinement.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |

#### Returns

`boolean`

#### Source

[abi/interface.ts:689](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L689)

***

### hasFunction()

```ts theme={null}
hasFunction(key): boolean
```

Returns true if `key` (a function selector, function name or function signature) is present in the ABI.

In the case of a function name, the name may be ambiguous, so accessing the
[**FunctionFragment**](/sdk/content/classes/FunctionFragment) may require refinement.

#### Parameters

| Parameter | Type     |
| :-------- | :------- |
| `key`     | `string` |

#### Returns

`boolean`

#### Source

[abi/interface.ts:575](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L575)

***

### parseError()

```ts theme={null}
parseError(data): null | ErrorDescription
```

Parses a revert data, finding the matching error and extracts the parameter values along with other useful error
details.

If the matching error cannot be found, returns null.

#### Parameters

| Parameter | Type                                               |
| :-------- | :------------------------------------------------- |
| `data`    | [`BytesLike`](/sdk/content/type-aliases/BytesLike) |

#### Returns

`null` | [`ErrorDescription`](/sdk/content/classes/ErrorDescription)

#### Source

[abi/interface.ts:1241](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L1241)

***

### parseLog()

```ts theme={null}
parseLog(log): null | LogDescription
```

Parses a receipt log, finding the matching event and extracts the parameter values along with other useful event
details.

If the matching event cannot be found, returns null.

#### Parameters

| Parameter    | Type        |
| :----------- | :---------- |
| `log`        | `object`    |
| `log.data`   | `string`    |
| `log.topics` | `string`\[] |

#### Returns

`null` | [`LogDescription`](/sdk/content/classes/LogDescription)

#### Source

[abi/interface.ts:1221](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L1221)

***

### parseTransaction()

```ts theme={null}
parseTransaction(tx): null | TransactionDescription
```

Parses a transaction, finding the matching function and extracts the parameter values along with other useful
function details.

If the matching function cannot be found, return null.

#### Parameters

| Parameter   | Type                                                     |
| :---------- | :------------------------------------------------------- |
| `tx`        | `object`                                                 |
| `tx.data`   | `string`                                                 |
| `tx.value`? | [`BigNumberish`](/sdk/content/type-aliases/BigNumberish) |

#### Returns

`null` | [`TransactionDescription`](/sdk/content/classes/TransactionDescription)

#### Source

[abi/interface.ts:1195](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L1195)

***

### from()

```ts theme={null}
static from(value): Interface
```

Creates a new [**Interface**](/sdk/content/classes/Interface) from the ABI `value`.

The `value` may be provided as an existing [**Interface**](/sdk/content/classes/Interface) object, a JSON-encoded ABI or any
Human-Readable ABI format.

#### Parameters

| Parameter | Type                                                                                                      |
| :-------- | :-------------------------------------------------------------------------------------------------------- |
| `value`   | [`Interface`](/sdk/content/classes/Interface) \| [`InterfaceAbi`](/sdk/content/type-aliases/InterfaceAbi) |

#### Returns

[`Interface`](/sdk/content/classes/Interface)

#### Source

[abi/interface.ts:1260](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/interface.ts#L1260)
