Setup Smart Account Client
How to setup your smart account client :
import {
createComethPaymasterClient,
createSafeSmartAccount,
createSmartAccountClient,
providerToSmartAccountSigner
} from "@cometh/connect-core-sdk";
import { arbitrumSepolia } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
import { http } from "viem";
const bundlerUrl = process.env.NEXT_PUBLIC_4337_BUNDLER_URL;
const paymasterUrl = process.env.NEXT_PUBLIC_4337_PAYMASTER_URL;
const signer = await providerToSmartAccountSigner(
window.ethereum
);
const publicClient = createPublicClient({
chain: arbitrumSepolia,
transport: http(),
cacheTime: 60_000,
batch: {
multicall: { wait: 50 },
},
});
const smartAccount = await createSafeSmartAccount({
chain: arbitrumSepolia,
publicClient,
signer,
})
const paymasterClient = await createComethPaymasterClient({
transport: http(paymasterUrl),
chain: arbitrumSepolia,
publicClient,
});
const smartAccountClient = createSmartAccountClient({
account: smartAccount,
chain,
bundlerTransport: http(bundlerUrl),
paymaster: paymasterClient,
userOperation: {
estimateFeesPerGas: async () => {
return await paymasterClient.getUserOperationGasPrice();
},
}
})
Last updated