Paymaster SDK Tutorial

📘

Preparation

Please read ZAN's account abstraction SDK tutorial to earn how to easily construct and send a UserOperation.

First you need to call the create policy API to create a new paymaster policy and get the policy id. Then call the update policy status API to activate the policy.

Please change code follow this:

const gasManagerConfig = process.env.PAYMASTER ? {gasManagerConfig : {policyId: process.env.PAYMASTER}} : {};

export const zanSmartAccountClient = createZanSmartAccountClient({
    rpcUrl,
    chain,
    account: await createLightAccount({
        transport: http(rpcUrl),
        chain,
        signer: eoaSigner,
    }),
    ...gasManagerConfig,
});

Add the PAYMASTER environment constant to .env file.

PAYMASTER = xxx //policy_id

Now you can try running the script to send a UserOperation sponsored by our AA Paymaster service!