# Create New Instance/s

### <mark style="color:purple;">createNewInstance</mark>

Create a new module instance.

```typescript
const createInstanceResult = await hatsModulesClient.createNewInstance({
    account,
    moduleId,
    hatId,
    immutableArgs,
    mutableArgs,
    saltNonce,
});
```

***Arguments***:

```typescript
{
    account: Account | Address;
    moduleId: string;
    hatId: bigint;
    immutableArgs: unknown[];
    mutableArgs: unknown[];
    saltNonce?: bigint;
}
```

* `account` - Viem account (Address for JSON-RPC accounts or Account for other types).
* `moduleId` - The module ID (implementation address).
* `hatId` - The hat ID for which the module is created.
* `immutableArgs` - The module's immutable args. The arguments should be in the same order as in the [Module](/for-developers/hats-modules/modules-sdk/types.md#module) object.
* `mutableArgs` - The module's mutable args. The arguments should be in the same order as in the [Module](/for-developers/hats-modules/modules-sdk/types.md#module) object.
* `saltNonce` - Optional salt nonce to use. If not provided, will be randomly generated.

***Response***:

```typescript
{
  status: "success" | "reverted";
  transactionHash: `0x${string}`;
  newInstance: `0x${string}`;
}
```

* `status` - "success" if transaction was successful, "reverted" if transaction reverted.
* `transactionHash` - transaction's hash.
* `newInstance` - In case of success, the address of the new module instance.

### <mark style="color:purple;">batchCreateNewInstances</mark>

Batch create new module instances.

Each module will be created according to the provided parameters, on the same corresponding array index.

```typescript
const createInstancesResult = await hatsModulesClient.batchCreateNewInstances({
    account,
    moduleIds,
    hatIds,
    immutableArgsArray,
    mutableArgsArray,
    saltNonces
});
```

***Arguments***:

```typescript
{
    account: Account | Address;
    moduleIds: string[];
    hatIds: bigint[];
    immutableArgsArray: unknown[][];
    mutableArgsArray: unknown[][];
    saltNonces?: bigint[]; 
}
```

* `account` - Viem account (Address for JSON-RPC accounts or Account for other types).
* `moduleIds` - The module IDs (implementation address).
* `hatIds` - The hat IDs for which the modules are created.
* `immutableArgsArray` - Each module's immutable arguments. For each module, the arguments should be in the same order as in the [Module](/for-developers/hats-modules/modules-sdk/types.md#module) object.
* `mutableArgsArray` - Each module's mutable arguments. For each module, the arguments should be in the same order as in the [Module](/for-developers/hats-modules/modules-sdk/types.md#module) object.
* `saltNonces` - Optional salt nonces to use. If not provided, will be randomly generated.

***Response***:

```typescript
{
  status: "success" | "reverted";
  transactionHash: `0x${string}`;
  newInstances: Array<`0x${string}`>;
}
```

* `status` - "success" if transaction was successful, "reverted" if transaction reverted.
* `transactionHash` - transaction's hash.
* `newInstances` - The address of the new module instances.

### <mark style="color:purple;">predictHatsModuleAddress</mark>

Predict a module's address before/after it was created, using its creation arguments.

```typescript
const predictedAddress = await hatsModulesClient.predictHatsModuleAddress({
    moduleId,
    hatId,
    immutableArgs,
    saltNonce,
});
```

***Arguments***:

```typescript
{
   moduleId: string;
   hatId: bigint;
   immutableArgs: unknown[];
   saltNonce: bigint;
}
```

* `moduleId` - Module's ID.
* `hatId` - The target hat ID, as provided to the [instance creation function](/for-developers/hats-modules/modules-sdk/create-new-instance-s.md#createnewinstance).
* `immutableArgs` - The module's immutable args, as provided to the [instance creation function](/for-developers/hats-modules/modules-sdk/create-new-instance-s.md#createnewinstance).
* `saltNonce` - Salt nonce to use.

***Response***:

```typescript
`0x${string}`
```

The predicted module address.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hatsprotocol.xyz/for-developers/hats-modules/modules-sdk/create-new-instance-s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
