• Calculates the required prefund amount for a user operation based on its gas parameters. The prefund amount is used to ensure the account has sufficient funds to cover the operation's gas costs. For v0.7.0, this includes separate verification gas limits for both the account and paymaster.

    Parameters

    • userOp: Pick<
          {
              callData: `0x${string}`;
              callGasLimit: bigint;
              factory: `0x${string}`;
              factoryData: `0x${string}`;
              maxFeePerGas: bigint;
              maxPriorityFeePerGas: bigint;
              nonce: bigint;
              paymaster: `0x${string}`;
              paymasterData: `0x${string}`;
              paymasterPostOpGasLimit?: bigint;
              paymasterVerificationGasLimit?: bigint;
              preVerificationGas: bigint;
              sender: `0x${string}`;
              signature: `0x${string}`;
              verificationGasLimit: bigint;
          },
          | "maxFeePerGas"
          | "preVerificationGas"
          | "verificationGasLimit"
          | "callGasLimit"
          | "paymasterVerificationGasLimit"
          | "paymasterPostOpGasLimit",
      >

      The user operation to calculate prefund for

      • verificationGasLimit

        Gas limit for account verification

      • callGasLimit

        Gas limit for the main execution call

      • preVerificationGas

        Gas for pre-verification operations

      • paymasterVerificationGasLimit

        Optional gas limit for paymaster verification

      • paymasterPostOpGasLimit

        Optional gas limit for paymaster post-operation execution

      • maxFeePerGas

        Maximum total fee per gas unit

    Returns bigint

    The required prefund amount in wei as a bigint

    // Without paymaster
    const prefund = getRequiredPrefundV7({
    verificationGasLimit: 50000n,
    callGasLimit: 100000n,
    preVerificationGas: 21000n,
    maxFeePerGas: 1000000000n
    });

    // With paymaster
    const prefundWithPaymaster = getRequiredPrefundV7({
    verificationGasLimit: 50000n,
    callGasLimit: 100000n,
    preVerificationGas: 21000n,
    paymasterVerificationGasLimit: 40000n,
    paymasterPostOpGasLimit: 20000n,
    maxFeePerGas: 1000000000n
    });

    The v0.7.0 version differs from v0.6.0 by handling paymaster gas limits separately rather than using a multiplier. This allows for more precise gas estimation and potentially lower prefund requirements.