Integration with Alchemy Account Kit
Alchemy Account Kit — complete stack for Account Abstraction from Alchemy: smart account implementation (Light Account), bundler, paymaster and React hooks. Goal: add AA to existing dApp in hours, not weeks.
Account Kit Components
Light Account — minimalist ERC-4337 compatible smart account implementation. Cheaper to deploy and use than Safe. Supports: single owner, session keys, EIP-1271 signature validation.
Modular Account — extensible account based on ERC-6900 (Modular Smart Account standard). Allows adding plugins: multisig, spending limits, social recovery.
Gas Manager (Paymaster) — gas sponsoring with policies: by amount, by number of operations, by whitelist of contract addresses.
Alchemy Bundler — built-in bundler into Alchemy infrastructure, with SLA and support for all major EVM chains.
Integration
import { createModularAccountAlchemyClient } from "@alchemy/aa-alchemy";
import { LocalAccountSigner, sepolia } from "@alchemy/aa-core";
import { http } from "viem";
const client = await createModularAccountAlchemyClient({
apiKey: "YOUR_ALCHEMY_API_KEY",
chain: sepolia,
signer: LocalAccountSigner.privateKeyToAccountSigner(privateKey),
gasManagerConfig: {
policyId: "YOUR_GAS_POLICY_ID",
},
});
// Send user operation without ETH on wallet
const { hash } = await client.sendUserOperation({
uo: {
target: contractAddress,
data: encodeFunctionData({ abi, functionName: "mint", args: [] }),
value: 0n,
},
});
await client.waitForUserOperationTransaction({ hash });
React Hooks
Account Kit provides @alchemy/aa-alchemy/react with ready-made hooks:
import {
AlchemyAccountProvider,
useSmartAccountClient,
useSendUserOperation,
} from "@alchemy/aa-alchemy/react";
function MintButton() {
const { client } = useSmartAccountClient({ type: "ModularAccount" });
const { sendUserOperation, isSendingUserOperation } = useSendUserOperation({
client,
waitForTxn: true,
});
return (
<button
onClick={() =>
sendUserOperation({
uo: { target: NFT_ADDRESS, data: mintCalldata, value: 0n },
})
}
disabled={isSendingUserOperation}
>
{isSendingUserOperation ? "Minting..." : "Mint NFT"}
</button>
);
}
Session Keys
Account Kit supports session keys — temporary keys with limited rights. User once confirms session key creation, then application can execute transactions without requesting signature each time:
const sessionKey = await client.createSessionKey({
expirationTime: Math.floor(Date.now() / 1000) + 3600, // 1 hour
permissions: [
{
type: "contract",
address: GAME_CONTRACT,
functionSelectors: [MOVE_SELECTOR, ATTACK_SELECTOR], // only specific functions
},
],
spendingLimit: parseEther("0.01"), // max 0.01 ETH per session
});
This is especially valuable for games and applications with frequent small transactions.
Alchemy Account Kit integration takes 1-2 weeks. Includes account type choice (Light vs Modular), Gas Manager policy setup, integration with existing auth flow and testnet testing. Alchemy provides generous free tier — suitable for MVP without initial costs.







