Alchemy AccountKit

Introduction

With Account Kit, you can create a smart account for every user in your application. With Account Kit, a new user will:

  • Create a smart account directly in your app without third-party downloads

  • Submit transactions without needing ETH in their account for gas

  • Submit transactions in the background without leaving your app

Enabled by ERC-4337, Account Kit makes it possible to build a web3 app that feels like web2: simple and familiar for mainstream users.

Getting Started

Get started with Account Kit at https://accountkit.alchemy.com/getting-started.html

Connecting Alchemy Account Kit to a Capsule Signer


import { AlchemyProvider } from "@alchemy/aa-alchemy";
import {
  LightSmartContractAccount,
  getDefaultLightAccountFactoryAddress,
} from "@alchemy/aa-accounts";
import { WalletClientSigner, type SmartAccountSigner } from "@alchemy/aa-core";
import { http } from "viem";
import { sepolia } from "viem/chains";

const CHAIN = sepolia;

// create capsule viem client
const viemClient = createCapsuleViemClient(capsule, {
  chain: CHAIN,
  transport: http(PROVIDER),
});

// create smart account signer type
const capsuleAccountKitSigner: SmartAccountSigner = new WalletClientSigner(
  viemClient,
  "capsule" // signerType
);

const provider = new AlchemyProvider({
  apiKey: "ALCHEMY_API_KEY",
  CHAIN,
}).connect(
  (rpcClient) =>
    new LightSmartContractAccount({
      chain,
      owner: capsuleAccountKitSigner,
      factoryAddress: getDefaultLightAccountFactoryAddress(chain),
      rpcClient,
    })
);

Note: for simplicity, Capsule imports are not included in the above- It is assumed that the Capsule object has been instantiated and the user has created a wallet. If you need access to Capsule or help getting set up, please see the Getting Started section

Last updated