Install and configure account abstraction providers like Alchemy, Biconomy, ZeroDev, and Safe
This guide shows you how to set up various account abstraction libraries to create and manage smart accounts using the standard and Para’s Viem integration. These libraries allow you to interact with smart accounts, send user operations, and sponsor gas fees for transactions.
import { type WalletClient, http, createWalletClient } from "viem";import { sepolia } from "viem/chains";import { useViemAccount } from "@getpara/react-sdk";import { WalletClientSigner } from "@aa-sdk/core";import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";import { alchemy } from "@account-kit/infra";import { useState, useEffect } from "react";// Configuration constants - Replace with your valuesconst CHAIN = sepolia; // Target chainconst ALCHEMY_RPC_URL = "https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_API_KEY"; // Replace with your Alchemy RPC URLconst GAS_POLICY_ID = "YOUR_ALCHEMY_GAS_POLICY_ID"; // Replace with your Alchemy gas policy IDconst salt = "YOUR_SALT"; // Used for account creation.export const useAlchemySmartAccount = () => { const { viemAccount, isLoading: accountLoading } = useViemAccount(); const [client, setClient] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { const initializeClient = async () => { if (!viemAccount || accountLoading) return; try { // Create a Viem WalletClient with the Para account const walletClient: WalletClient = createWalletClient({ account: viemAccount, chain: CHAIN, transport: http(ALCHEMY_RPC_URL) }); // Create WalletClientSigner from the Viem WalletClient const walletClientSigner = new WalletClientSigner(walletClient, "wallet"); // Create modular account Alchemy client with the WalletClientSigner const alchemyClient = await createModularAccountAlchemyClient({ transport: alchemy({ rpcUrl: ALCHEMY_RPC_URL }), chain: CHAIN, signer: walletClientSigner, policyId: GAS_POLICY_ID, salt, }); setClient(alchemyClient); } catch (error) { console.error("Failed to initialize Alchemy client:", error); } finally { setIsLoading(false); } }; initializeClient(); }, [viemAccount, accountLoading]); return { client, isLoading: isLoading || accountLoading };};
Smart Wallets contracts are deployed automatically on the first transaction by the provider. Meaning you don’t need to deploy them manually. However, you can deploy them manually if you want by signing and sending an empty transaction.