# createModularAccountV2 | @account-kit/smart-contracts

> Creates a ModularAccount V2 account, with the mode depending on the provided "mode" field. Possible modes include: "default", which is SMA Bytecode, and "7702", which is SMA 7702. Handles nonce generation, transaction encoding, and mode variant-specific behavior like initcode construction.

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

Creates a ModularAccount V2 account, with the mode depending on the provided "mode" field.
Possible modes include: "default", which is SMA Bytecode, and "7702", which is SMA 7702.
Handles nonce generation, transaction encoding, and mode variant-specific behavior like initcode construction.

## Example

```ts twoslash
import { createModularAccountV2 } from "@account-kit/smart-contracts";
import { LocalAccountSigner } from "@aa-sdk/core";
import { alchemy, sepolia } from "@account-kit/infra";

const MNEMONIC = "...";
const RPC_URL = "...";

const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);

const chain = sepolia;

const transport = alchemy({ rpcUrl: RPC_URL });

const modularAccountV2 = await createModularAccountV2({
  mode: "default", // or "7702"
  chain,
  signer,
  transport,
});
```

## Param

Configuration parameters for creating a Modular Account V2.

## Call Signature

```ts
function createModularAccountV2<TTransport, TSigner>(
  config,
): Promise<ModularAccountV2<TSigner>>;
```

Defined in: [account-kit/smart-contracts/src/ma-v2/account/modularAccountV2.ts:87](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/smart-contracts/src/ma-v2/account/modularAccountV2.ts#L87)

### Type Parameters

<table>
  <thead>
    <tr>
      <th align="left">Type Parameter</th>
      <th align="left">Default type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `TTransport` *extends* [`Transport`](https://viem.sh)
      </td>

      <td>
        [`Transport`](https://viem.sh)
      </td>
    </tr>

    <tr>
      <td>
        `TSigner` *extends* `SmartAccountSigner`\<`any`>
      </td>

      <td>
        `SmartAccountSigner`\<`any`>
      </td>
    </tr>

  </tbody>
</table>

### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `config`
      </td>

      <td>
        [`CreateModularAccountV2Params`](../type-aliases/CreateModularAccountV2Params)\<`TTransport`, `TSigner`>
      </td>
    </tr>

  </tbody>
</table>

### Returns

`Promise`\<[`ModularAccountV2`](../type-aliases/ModularAccountV2)\<`TSigner`>>

## Call Signature

```ts
function createModularAccountV2<TTransport>(
  config,
): Promise<WebauthnModularAccountV2>;
```

Defined in: [account-kit/smart-contracts/src/ma-v2/account/modularAccountV2.ts:94](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/smart-contracts/src/ma-v2/account/modularAccountV2.ts#L94)

### Type Parameters

<table>
  <thead>
    <tr>
      <th align="left">Type Parameter</th>
      <th align="left">Default type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `TTransport` *extends* [`Transport`](https://viem.sh)
      </td>

      <td>
        [`Transport`](https://viem.sh)
      </td>
    </tr>

  </tbody>
</table>

### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `config`
      </td>

      <td>
        [`CreateWebauthnModularAccountV2Params`](../type-aliases/CreateWebauthnModularAccountV2Params)\<`TTransport`>
      </td>
    </tr>

  </tbody>
</table>

### Returns

`Promise`\<[`WebauthnModularAccountV2`](../type-aliases/WebauthnModularAccountV2)>