AA only chains or non-Alchemy chains
If you're using a chain that isn't supported by us or we only support Account Abstraction methods for those chains, then you can use createSmartAccountClient
or one of non-alchemy create*Client
methods from @account-kit/smart-contracts
with a split
transport to route your traffic accordingly.
AA only chains example
import { createLightAccountClient } from "@account-kit/smart-contracts";
import {
createAlchemyPublicRpcClient,
zora,
alchemyFeeEstimator,
type ClientWithAlchemyMethods,
alchemyGasManagerMiddleware,
} from "@account-kit/infra";
import { split, LocalAccountSigner, createBundlerClient } from "@aa-sdk/core";
import { http, custom } from "viem";
const alchemyMethods = [
"eth_sendUserOperation",
"eth_estimateUserOperationGas",
"eth_getUserOperationReceipt",
"eth_getUserOperationByHash",
"eth_supportedEntryPoints",
"rundler_maxPriorityFeePerGas",
"pm_getPaymasterData",
"pm_getPaymasterStubData",
];
const transport = split({
overrides: [
{
methods: alchemyMethods,
transport: http("ALCHEMY_RPC_URL"),
},
],
fallback: http("ZORA_NODE_RPC_URL"),
});
const alchemyBundlerClient = createBundlerClient({
// zora is an example of an aa only chain
chain: zora,
transport,
}) as unknown as ClientWithAlchemyMethods;
const smartAccountClient = createLightAccountClient({
transport,
chain: zora,
feeEstimator: alchemyFeeEstimator(alchemyBundlerClient),
signer: LocalAccountSigner.generatePrivateKeySigner(),
// if you want to sponsor gas add this
...alchemyGasManagerMiddleware("YOUR_POLICY_ID"),
});
Non-Alchemy chains example
To use non-Alchemy supported chains, you can use the createSmartAccountClient
method from @aa-sdk/core
or any of the non-Alchemy create*Client
methods exported from @account-kit/smart-contracts
with a chain
definition for your chain and a transport
pointing to your RPC provider.
See createSmartAccountClient
for more information.