You aren't limited to the accounts defined in @alchemy/smart-accounts. If you'd like to bring your own smart account, you have two options:
- Use any library that returns a viem-compatible
SmartAccount— those plug into the samecreateBundlerClientflow we use for Light Account and Modular Account V2. - Build your own
SmartAccountimplementation with viem'stoSmartAccountprimitive.
Any object that satisfies viem's SmartAccount interface works:
import { createBundlerClient } from "viem/account-abstraction";
import { createClient } from "viem";
import { sepolia } from "viem/chains";
import { alchemyTransport } from "@alchemy/common";
import { estimateFeesPerGas } from "@alchemy/aa-infra";
import { myAccount } from "./my-account"; // your custom SmartAccount
const transport = alchemyTransport({ apiKey: "your-api-key" });
const rpcClient = createClient({ chain: sepolia, transport });
const bundlerClient = createBundlerClient({
account: myAccount,
client: rpcClient,
chain: sepolia,
transport,
userOperation: { estimateFeesPerGas },
});
const hash = await bundlerClient.sendUserOperation({
calls: [{ to: "0x0000000000000000000000000000000000000000", value: 0n, data: "0x" }],
});Use toSmartAccount from viem/account-abstraction. You provide:
- The entry point version your account uses (
0.6,0.7, or0.8). getAddress()— counterfactual or deployed address.getFactoryArgs()— factory address + calldata (for first-time deploys).encodeCalls()— encode one or more calls into your account's execution calldata.signUserOperation()/signMessage/signTypedData— signing methods bound to your account's owner.
The viem docs walk through a full custom example. Once you have a SmartAccount, pass it to createBundlerClient exactly like the snippet above.
Built an SDK or guide that defines a custom SmartAccount for Wallet APIs? Open a PR to add it here.
@alchemy/smart-accounts ships viem-compatible implementations of Light Account, Modular Account V1, and Modular Account V2, plus the validation/permission builders for MAv2. If your use case fits one of those, you'll save a lot of custom-account boilerplate.
If you want to keep Alchemy's smart account implementations while using non-Alchemy infrastructure, see the low-level infrastructure guides:
- Non-Alchemy chains — run
@alchemy/smart-accountson a chain Alchemy doesn't support. - Third-party bundlers — submit user operations through another bundler RPC.
- Third-party paymasters — sponsor user operations with a non-Alchemy paymaster.