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

# AbiCoder

The **AbiCoder** is a low-level class responsible for encoding JavaScript values into binary data and decoding binary
data into JavaScript values.

## Methods

### decode()

```ts theme={null}
decode(
   types, 
   data, 
   loose?): Result
```

Decode the ABI data as the types into values.

If loose decoding is enabled, then strict padding is not enforced. Some older versions of Solidity incorrectly
padded event data emitted from `external` functions.

#### Parameters

| Parameter | Type                                                                    | Description                               |
| :-------- | :---------------------------------------------------------------------- | :---------------------------------------- |
| `types`   | readonly (`string` \| [`ParamType`](/sdk/content/classes/ParamType))\[] | Array of parameter types.                 |
| `data`    | [`BytesLike`](/sdk/content/type-aliases/BytesLike)                      | The ABI data to decode.                   |
| `loose`?  | `boolean`                                                               | Enable loose decoding. Default is `false` |

#### Returns

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

The decoded values.

#### Source

[abi/abi-coder.ts:223](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/abi-coder.ts#L223)

***

### encode()

```ts theme={null}
encode(types, values): string
```

Encode the values as the specified types into ABI data.

#### Parameters

| Parameter | Type                                                                    | Description                |
| :-------- | :---------------------------------------------------------------------- | :------------------------- |
| `types`   | readonly (`string` \| [`ParamType`](/sdk/content/classes/ParamType))\[] | Array of parameter types.  |
| `values`  | readonly `any`\[]                                                       | Array of values to encode. |

#### Returns

`string`

The encoded data in hexadecimal format.

#### Source

[abi/abi-coder.ts:201](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/abi-coder.ts#L201)

***

### getDefaultValue()

```ts theme={null}
getDefaultValue(types): Result
```

Get the default values for the given types. For example, a `uint` is by default `0` and `bool` is by default
`false`.

#### Parameters

| Parameter | Type                                                                    | Description                                         |
| :-------- | :---------------------------------------------------------------------- | :-------------------------------------------------- |
| `types`   | readonly (`string` \| [`ParamType`](/sdk/content/classes/ParamType))\[] | Array of parameter types to get default values for. |

#### Returns

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

The default values corresponding to the given types.

#### Source

[abi/abi-coder.ts:188](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/abi-coder.ts#L188)

***

### defaultAbiCoder()

```ts theme={null}
static defaultAbiCoder(): AbiCoder
```

Returns the shared singleton instance of a default [**AbiCoder**](/sdk/content/classes/AbiCoder).

On the first call, the instance is created internally.

#### Returns

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

The default ABI coder instance.

#### Source

[abi/abi-coder.ts:252](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/abi-coder.ts#L252)

***

### getBuiltinCallException()

```ts theme={null}
static getBuiltinCallException(
   action, 
   tx, 
   data): CallExceptionError
```

Returns a quais-compatible [**CallExceptionError**](/sdk/content/interfaces/CallExceptionError) for the given result data.

#### Parameters

| Parameter  | Type                                                                   | Description                                  |
| :--------- | :--------------------------------------------------------------------- | :------------------------------------------- |
| `action`   | [`CallExceptionAction`](/sdk/content/type-aliases/CallExceptionAction) | The action that triggered the exception.     |
| `tx`       | `object`                                                               | The transaction information.                 |
| `tx.data`? | `string`                                                               | -                                            |
| `tx.from`? | `null` \| `string`                                                     | -                                            |
| `tx.to`?   | `null` \| `string`                                                     | -                                            |
| `data`     | `null` \| [`BytesLike`](/sdk/content/type-aliases/BytesLike)           | The data associated with the call exception. |

#### Returns

[`CallExceptionError`](/sdk/content/interfaces/CallExceptionError)

The corresponding call exception error.

#### Source

[abi/abi-coder.ts:267](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/abi/abi-coder.ts#L267)
