Skip to content

Getting started with Modular Account

It is easy to get started with Modular Account! We will show you two different ways using Alchemy Infra or 3rd party infra.

Install packages

Prerequisites Installation

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

yarn
yarn add @account-kit/smart-contracts
# if using alchemy infra
yarn add @account-kit/infra

With Alchemy Infra

Then you can do the following:

import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";
import { sepolia, alchemy } from "@account-kit/infra";
import { LocalAccountSigner } from "@aa-sdk/core";
import { generatePrivateKey } from "viem/accounts";
 
const alchemyAccountClient = await createModularAccountAlchemyClient({
  transport: alchemy({ apiKey: "your-api-key" }),
  chain: sepolia,
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});

With 3rd-party infra

If you're using a 3rd-party for infra, we also expose a client that you can use to interact with Modular Account using other RPC providers.

import { createMultiOwnerModularAccountClient } from "@account-kit/smart-contracts";
import { LocalAccountSigner } from "@aa-sdk/core";
import { sepolia } from "viem/chains";
import { http } from "viem";
import { generatePrivateKey } from "viem/accounts";
 
const accountClient = await createMultiOwnerModularAccountClient({
  chain: sepolia,
  transport: http("RPC_URL"),
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});

Next, if you want to use a different signer with a smart account signer, check out choosing a signer. Otherwise, if you are ready to get on-chain, go to send user operations.