3rd Party Paymasters

The SmartAccountClient within @aa-sdk/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

import { 
function createSmartAccountClient<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>): SmartAccountClient<TTransport, TChain, TAccount>
createSmartAccountClient
} from "@aa-sdk/core";
import {
function http<rpcSchema extends RpcSchema | undefined = undefined, raw extends boolean = false>(url?: string | undefined, config?: HttpTransportConfig<rpcSchema, raw>): HttpTransport<rpcSchema, raw>
http
} from "viem";
import {
const sepolia: { blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://sepolia.etherscan.io"; readonly apiUrl: "https://api-sepolia.etherscan.io/api"; }; }; ... 11 more ...; serializers?: ChainSerializers<...> | undefined; }
sepolia
} from "viem/chains";
const
const chain: { blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://sepolia.etherscan.io"; readonly apiUrl: "https://api-sepolia.etherscan.io/api"; }; }; ... 11 more ...; serializers?: ChainSerializers<...> | undefined; }
chain
=
const sepolia: { blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://sepolia.etherscan.io"; readonly apiUrl: "https://api-sepolia.etherscan.io/api"; }; }; ... 11 more ...; serializers?: ChainSerializers<...> | undefined; }
sepolia
;
const
const client: { [x: string]: unknown; account: SmartContractAccount | undefined; batch?: { multicall?: boolean | Prettify<MulticallBatchOptions> | undefined; } | undefined; ... 83 more ...; extend: <const client extends { ...; } & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>; }
client
=
createSmartAccountClient<HttpTransport<undefined, false>, { blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://sepolia.etherscan.io"; readonly apiUrl: "https://api-sepolia.etherscan.io/api"; }; }; ... 11 more ...; serializers?: ChainSerializers<...> | undefined; }, SmartContractAccount | undefined, UserOperationContext | undefined>(config: { ...; }): { ...; }
createSmartAccountClient
({
chain?: Chain | { blockExplorers: { readonly default: { readonly name: "Etherscan"; readonly url: "https://sepolia.etherscan.io"; readonly apiUrl: "https://api-sepolia.etherscan.io/api"; }; }; ... 11 more ...; serializers?: ChainSerializers<...> | undefined; } | undefined

Chain for the client.

chain
,
transport: HttpTransport<undefined, false>

The RPC transport

transport
:
http<undefined, false>(url?: string | undefined, config?: HttpTransportConfig<undefined, false> | undefined): HttpTransport<undefined, false>
http
("RPC_URL"),
// sets the dummy paymasterAndData with paymaster address appended with some dummy paymasterData // that looks like a valid paymasterData
dummyPaymasterAndData?: ClientMiddlewareFn<UserOperationContext | undefined> | undefined
dummyPaymasterAndData
: async (
userop: Deferrable<UserOperationStruct<TEntryPointVersion>>
userop
) => ({
...
userop: Deferrable<UserOperationStruct<TEntryPointVersion>>
userop
,
paymasterAndData: string
paymasterAndData
: `0x<PAYMASTER_ADDRESS><PAYMASTER_DUMMY_DATA>`,
}),
paymasterAndData?: ClientMiddlewareFn<UserOperationContext | undefined> | undefined
paymasterAndData
: async (
userop: Deferrable<UserOperationStruct<TEntryPointVersion>>
userop
,
opts: ClientMiddlewareArgs<TAccount, C, UserOperationContext | undefined, TEntryPointVersion>
opts
) => {
// call your paymaster here to sponsor the userop // leverage the `opts` field to apply any overrides return { ...
userop: Deferrable<UserOperationStruct<TEntryPointVersion>>
userop
,
paymasterAndData: string
paymasterAndData
: "0xresponsefromprovider",
}; }, });