Implementing Pimlico with Web3Auth

Hi, I’m implementing Pimlico with Web3Auth. I created the account abstraction provider, and using that, I set up a provider and signer. However, I’m encountering an error while trying to transfer ERC20 tokens via the paymaster.

Hello Parvinder Kumar,

Thank you for reaching out! It looks like you’re working on integrating Pimlico with Web3Auth’s Plug n Play SDK and facing an issue while transferring ERC20 tokens using a paymaster.

Could you please provide:

  • The specific SDK version number you’re using with Plug n Play?
  • A snippet of your initialization and login code?
  • Any console logs or error messages visible in the screenshot?

With these details, the support team will be better equipped to assist you. Let me know if there’s anything else you need in the meantime. :blush:

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Hi parvinder,

based on the user operation payload and error message, it seems that the you have yet to approve the paymaster (0x0000000000000039cd5e8aE05257CE51C473ddd1) to spend USDC (0x1c7d4b196cb0c7b01d743fbc6116a902379c7238) on your account’s (0xabBb6e4455482861dC3CE16b604698782E3B782a) behalf.

It should work if you include an approval call in your user operation’s callData field.

Pseudocode example using viem:

import { encodeFunctionData, erc20Abi, maxUint256 } from viem

await account.encodeCalls([
  // Approve the paymaster to spend USDC
  {
    to: "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",  // USDC
    value: 0n,
    data: encodeFunctionData({
      abi: erc20Abi,
      functionName: "approve",
      // [paymasterAddress, amount]
      args: ["0x0000000000000039cd5e8aE05257CE51C473ddd1", maxUint256],
    }),
  },
])