Skip to content
Alchemy Logo

Quickstart

In this guide, you'll wire up viem's bundler client to Alchemy's bundler with a Modular Account V2 from @alchemy/smart-accounts and send a user operation. This is the advanced path; if you don't need this level of control, use @alchemy/wallet-apis instead.

Installation

yarn add @alchemy/common @alchemy/aa-infra @alchemy/smart-accounts viem

Replace YOUR_API_KEY and POLICY_ID with the values from the prerequisites above.

config.ts
import { sepolia } from "viem/chains";
 
export const chain = sepolia;
export const ALCHEMY_API_KEY = "<YOUR_API_KEY>";
export const policyId = "<POLICY_ID>";

import { getClient } from "./client";
 
const client = await getClient();
 
const hash = await client.sendUserOperation({
  calls: [
    {
      to: "0x0000000000000000000000000000000000000000",
      value: 0n,
      data: "0x",
    },
  ],
});
 
const receipt = await client.waitForUserOperationReceipt({ hash });
console.log("Mined:", receipt.receipt.transactionHash);
Was this page helpful?