Skip to content

ERC20 GAS SPONSORSHIP NOT WORKING #32

@LawrenceKU03

Description

@LawrenceKU03

I am trying to allow users sponsor gas in usdc/my community erc20 token but it still keeps using gas from the eth i sent earlier and not usdc

const chain = base;
const ZERODEV_RPC = `https://rpc.zerodev.app/api/v3/${
  import.meta.env.VITE_ZERO_DEV_APP_ID
}/chain/${chain.id}`;

const entryPoint = getEntryPoint("0.7");

const paymasterClient = createZeroDevPaymasterClient({
  chain,
  transport: http(ZERODEV_RPC),
});

const createOrder = async (serviceName: string, approvedAmount: number) => {
  const { kernelClient } = useQuiverStore.getState();
  const data = encodeFunctionData({
    abi: QuiverPayManagerABI,
    functionName: "createOrder",
    args: [approvedAmount, serviceName],
  });

  const userOpHash = await kernelClient.sendUserOperation({
    callData: await kernelClient.account.encodeCalls([
       await getERC20PaymasterApproveCall(paymasterClient, {
        gasToken: TA,
        approveAmount: parseEther("0.0035"),
        entryPoint,
      }),
      {
        to: CA,
        value: BigInt(0),
        data: data,
      },
    ]),
  });

  await kernelClient.waitForUserOperationReceipt({
    hash: userOpHash,
    timeout: 1000 * 15,
  });
};
``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions