Skip to content

Using a third-party paymaster

The SmartAccountClient within @alchemy/aa-core is unopinionated about which paymaster you use, so you can connect to any paymaster really simply. Configuration is done using the paymasterAndData config option when you call createSmartAccountClient.

Usage

ts
import { createSmartAccountClient } from "@alchemy/aa-core";
import { sepolia } from "viem";

const chain = sepolia;
const client = createSmartAccountClient({
  chain,
  transport: http("RPC_URL"),
  paymasterAndData: {
    paymasterAndData: async (userop, opts) => {
        // call your paymaster here to sponsor the userop
        // leverage the `opts` field to apply any overrides
        return {
            ...userop,
            paymasterAndData: "0xresponsefromprovider"
        }
    },
    dummyPaymasterAndData: () => "0xnonrevertingpaymasterandata,
  },
});