# Modular Account V2 • Getting started

> Getting started with Modular Account V2 in Wallet APIs

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

Getting started with Modular Account v2 is straightforward. Below, you create a new Modular Account v2 client to send transactions. Your MAv2 smart account deploys onchain when you send the first transaction from a unique owner.

## Install packages

**Prerequisites**

* minimum Typescript version of 5

**Installation**

First, install the `@account-kit/smart-contracts` package.

<CodeBlocks>
  ```bash yarn
  yarn add @account-kit/smart-contracts
  yarn add @account-kit/infra
  ```

  ```bash npm
  npm install @account-kit/smart-contracts
  npm install @account-kit/infra
  ```
</CodeBlocks>

<Tip title="Address calculation">
  For Modular Account V2, the address of the smart account will be calculated as a combination of [the owner and the salt](https://github.com/alchemyplatform/modular-account/blob/v2.0.x/src/factory/AccountFactory.sol#L98-L104). You will get the same smart account address each time you supply the same `owner`, the signer(s) used to create the account for the first time. You can also optionally supply `salt` if you want a different address for the same `owner` param (the default salt is `0n`).

  If you want to use a signer to connect to an account whose address does not map to the contract-generated address, you can supply the `accountAddress` to connect with the account of interest. In that case, the `signer` address is not used for address calculation, but only for signing the operation.
</Tip>

## Creating a Modular Account V2 client

```ts twoslash modular-account-v2.ts
import { createModularAccountV2Client } from "@account-kit/smart-contracts";
import { LocalAccountSigner } from "@aa-sdk/core";
import { sepolia, alchemy } from "@account-kit/infra";
import { generatePrivateKey } from "viem/accounts";

const accountClient = await createModularAccountV2Client({
  mode: "default", // optional param to specify the MAv2 variant (either "default" or "7702")
  chain: sepolia,
  transport: alchemy({ apiKey: "your-api-key" }), // Get your API key at https://dashboard.alchemy.com/apps or http("RPC_URL") for non-alchemy infra
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});
```

**Choosing which mode to use**
Two variants of Modular Account v2 are available: `default` and `7702`.

* (Recommended) `default` provides you with the cheapest, most flexible and advanced smart wallet
* `7702` if you are looking for 7702 support, learn about how to set up and take advantage of the EIP-7702 compliant account [here](/docs/wallets/transactions/using-eip-7702)

Want to enable social login methods? Set up your [authentication provider](/docs/wallets/signer/quickstart).

Alternatively, you can [bring a 3rd party authentication provider](/docs/wallets/third-party/signers/privy) as the owner of your new account.

Not sure what authentication provider to use? [Learn more](/docs/wallets/signer/what-is-a-signer).

## Sending a transaction

Now that you have a client, you can send a transaction. The first transaction also deploys the new Modular Account v2.

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

const accountClient = await createModularAccountV2Client({
  chain: sepolia,
  transport: alchemy({ apiKey: "your-api-key" }),
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});

const operation = await accountClient.sendUserOperation({
  // simple UO sending no data or value to vitalik's address
  uo: {
    target: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // The address to call in the UO
    data: "0x", // The calldata to send in the UO
    value: parseEther("0"), // The value to send in the UO
  },
});

console.log(
  "User operation sent! \nUO hash: ",
  operation.hash,
  "\nModular Account v2 Address: ",
  operation.request.sender,
);
```