Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Biconomy as custom Paymaster on permissionless #590

Open
1 task done
NikZak opened this issue Nov 11, 2024 · 1 comment
Open
1 task done

[BUG] Biconomy as custom Paymaster on permissionless #590

NikZak opened this issue Nov 11, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@NikZak
Copy link

NikZak commented Nov 11, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.0.8

Current Behavior

I am trying to make biconomy work as custom paymaster with permissionless/pimlico code. Here is my code

import { createSmartAccountClient, SmartAccountClient } from "permissionless";
import { createPimlicoClient } from "permissionless/clients/pimlico";
import { createBicoPaymasterClient } from "@biconomy/sdk";

import { createPublicClient, http, zeroAddress } from "viem";
import { arbitrumSepolia } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
import {
  entryPoint07Address,
  SendUserOperationReturnType,
} from "viem/account-abstraction";
import { toEcdsaKernelSmartAccount } from "permissionless/accounts";

enum PaymasterProvider {
  PIMLICO,
  BICONOMY,
}
export const safeMultiplier = (bI: bigint, multiplier: number): bigint =>
  BigInt(Math.round(Number(bI) * multiplier));

const paymasterProvider: PaymasterProvider = PaymasterProvider.BICONOMY;

const owner = privateKeyToAccount(
  MY_PRIVATE_KEY
);
const chain = arbitrumSepolia;
const chainId = chain.id;
const PIMLICO_PAYMASTER_RPC = ...;
const BICONOMY_PAYMASTER_RPC = ...;

const bundlerRpc = PIMLICO_PAYMASTER_RPC;

const publicClient = createPublicClient({
  transport: http(chain.rpcUrls.default.http[0]),
  chain: chain,
});

const pimlicoClient = createPimlicoClient({
  transport: http(PIMLICO_PAYMASTER_RPC),
  entryPoint: {
    address: entryPoint07Address,
    version: "0.7",
  },
});
console.log("pimlico client created");
const biconomyPaymasterClient = createBicoPaymasterClient({
  paymasterUrl: BICONOMY_PAYMASTER_RPC,
});
console.log("biconomy client created");

async function main() {
  const kernelAccount = await toEcdsaKernelSmartAccount({
    client: publicClient,
    entryPoint: {
      address: entryPoint07Address,
      version: "0.7",
    },
    owners: [owner],
  });
  console.log("smartaccount address", kernelAccount.address);
  let smartAccountClient: SmartAccountClient;
  // do a case switch here
  switch (paymasterProvider) {
    case PaymasterProvider.PIMLICO: {
      smartAccountClient = createSmartAccountClient({
        account: kernelAccount,
        chain: chain,
        paymaster: pimlicoClient,
        bundlerTransport: http(bundlerRpc),
        userOperation: {
          estimateFeesPerGas: async () =>
            (await pimlicoClient.getUserOperationGasPrice()).fast,
        },
      });
      break;
    }
    case PaymasterProvider.BICONOMY: {
      smartAccountClient = createSmartAccountClient({
        account: kernelAccount,
        chain: chain,
        paymasterContext: {
          mode: "SPONSORED",
          calculateGasLimits: true,
          expiryDuration: 300, // duration (secs) for which the generate paymasterAndData will be valid. Default duration is 300 secs.
          sponsorshipInfo: {
            webhookData: {},
            smartAccountInfo: {
              name: "BICONOMY",
              version: "2.0.0",
            },
          },
        },
        paymaster: biconomyPaymasterClient,
        bundlerTransport: http(bundlerRpc),
        userOperation: {
          estimateFeesPerGas: async (_) => {
            const feeData = await publicClient.estimateFeesPerGas();
            return {
              maxFeePerGas: safeMultiplier(feeData.maxFeePerGas, 1.25),
              maxPriorityFeePerGas: safeMultiplier(
                feeData.maxPriorityFeePerGas,
                1.25
              ),
            };
          },
        },
      });
      break;
    }
  }

  let userOpHash: SendUserOperationReturnType;
  switch (paymasterProvider) {
    case PaymasterProvider.PIMLICO: {
      userOpHash = await smartAccountClient.sendUserOperation({
        entryPointAddress: entryPoint07Address,
        calls: [
          {
            to: zeroAddress,
            value: BigInt(0),
            data: "0x",
          },
        ],
      });

      break;
    }
    case PaymasterProvider.BICONOMY: {
      userOpHash = await smartAccountClient.sendUserOperation({
        entryPointAddress: entryPoint07Address,
        calls: [
          {
            to: zeroAddress,
            value: BigInt(0),
            data: "0x",
          },
        ],
      });
      break;
    }
  }
  console.log(userOpHash);
}

main().catch(console.error);

Expected Behavior

I want it to just work and send transactions.

but i get this error from biconomy API

Request body: {"method":"pm_getPaymasterData","params":[{"callData":"0xe9ae5c5300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","maxFeePerGas":"0x8f0d180","maxPriorityFeePerGas":"0x0","nonce":"0x8104e3ad430ea6d354d013a6789fdfc71e671c4300000000000000000008","sender":"0x0aA2b7FAA6Ad5D53A4D36B8BE28f38cDD23d29C2","signature":"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c","callGasLimit":"0x0","verificationGasLimit":"0x0","preVerificationGas":"0x0"},"0x0000000071727De22E5E9d8BAf0edAc6f37da032","0x66eee",{"mode":"SPONSORED","calculateGasLimits":true,"expiryDuration":300,"sponsorshipInfo":{"webhookData":{},"smartAccountInfo":{"name":"BICONOMY","version":"2.0.0"}}}]}

Details: {"code":417,"message":"Entry Point does not match"}
Version: viem@2.21.43

Steps To Reproduce

see above

Package.json (or lockfile) content

{
  "name": "t3_vc_demo",
  "version": "0.0.1",
  "description": "Demo of VC functionality",
  "main": "index.js",
  "author": "Nikolay Zakirov",
  "license": "MIT",
  "type": "module",
  "dependencies": {
    "@biconomy/paymaster": "^3.1.4",
    "@biconomy/sdk": "^0.0.8",
    "@rhinestone/module-sdk": "^0.1.28",
    "@zerodev/ecdsa-validator": "^5.3.3",
    "@zerodev/sdk": "^5.3.26",
    "permissionless": "0.2.15",
    "tslib": "^2.8.1",
    "viem": "^2.21.43"
  },
  "devDependencies": {
    "@types/asciify": "^1.3.33",
    "jest": "^29.7.0",
    "nodemon": "^3.1.2",
    "ts-jest": "^29.1.4",
    "ts-node": "^10.9.2",
    "typescript": "^5.4.5"
  },
  "scripts": {
    "start": "node ./bin/index.js",
    "dev": "nodemon --exec npx tsx ./src/index.ts",
    "test": "npx jest --detectOpenHandles",
    "build": "tsc -p ."
  }
}

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

No response

Anything else?

na

@NikZak NikZak added bug Something isn't working help wanted Extra attention is needed labels Nov 11, 2024
@NikZak
Copy link
Author

NikZak commented Nov 13, 2024

and if I change the entryppoint to 06 I get

const entryPointAddress = entryPoint06Address;
Request body: {"method":"pm_getPaymasterData","params":[{"callData":"0xe9ae5c5300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","maxFeePerGas":"0x8f0d180","maxPriorityFeePerGas":"0x0","nonce":"0x8104e3ad430ea6d354d013a6789fdfc71e671c4300000000000000000000","sender":"0x0aA2b7FAA6Ad5D53A4D36B8BE28f38cDD23d29C2","signature":"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c","callGasLimit":"0x0","verificationGasLimit":"0x0","preVerificationGas":"0x0"},"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789","0x66eee",{"mode":"SPONSORED","calculateGasLimits":true,"expiryDuration":300,"sponsorshipInfo":{"webhookData":{},"smartAccountInfo":{"name":"BICONOMY","version":"2.0.0"}}}]}

Details: {"code":417,"message":"Cannot read properties of undefined (reading 'length')"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant