EIPs Explained

ERC-7677 · Review · ERC · 2024-04-03

ERC-7677: Paymaster Web Service Capability

Lets an app tell a smart wallet which paymaster web service should sponsor its gas, and standardizes the two JSON-RPC calls wallets use to talk to that service.

What problem does it solve?

With ERC-4337 smart accounts, a paymaster can pay gas on a user's behalf. In practice paymasters are run as web services: the app signs up with a provider and gets a URL. But there was no standard way for an app to tell the user's wallet "use this paymaster for these calls", and every provider exposed a slightly different API, so wallets could not integrate them generically.

ERC-7677 fixes both sides: a wallet capability that carries the paymaster URL from the app, and a common two-method API that every paymaster service implements.

How it works

Paymaster service API. Both methods take the same params: [userOp, entryPoint, chainId, context]. The user operation is unsigned, and context holds provider-specific fields (for example a policy ID).

  • pm_getPaymasterStubData returns placeholder paymaster fields used only for gas estimation. For EntryPoint v0.7 it must also return paymasterPostOpGasLimit, because the paymaster pays for post-op and cannot trust the wallet's estimate. It may return a sponsor object (name, optional data-URI icon) that the wallet can show, and isFinal: true if no second call is needed.
  • pm_getPaymasterData returns the real paymaster fields (paymasterAndData for v0.6, or paymaster + paymasterData for v0.7) once gas values are settled. The user then signs.

Stub data must be the same length as the final data, have no more zero bytes, and follow the same code path in validatePaymasterUserOp/postOp; otherwise preVerificationGas or gas limits are underestimated.

Wallet capability. Building on EIP-5792:

  1. The wallet advertises paymasterService: { supported: true } per chain in wallet_getCapabilities.
  2. The app passes paymasterService: { url, context } in wallet_sendCalls.
  3. The wallet calls stub data, estimates gas with its bundler, calls paymaster data, asks the user to sign, and submits.

Gas estimation deliberately stays with the wallet, since it knows which bundler it will use. The chain ID parameter lets providers offer one URL for many chains if they want.

Sample code

App side, using an EIP-1193 provider:

const caps = await provider.request({
  method: "wallet_getCapabilities",
  params: [account],
});

if (caps["0x2105"]?.paymasterService?.supported) {
  await provider.request({
    method: "wallet_sendCalls",
    params: [{
      version: "1.0",
      chainId: "0x2105",
      from: account,
      calls: [{ to: target, value: "0x0", data: calldata }],
      capabilities: {
        paymasterService: {
          url: "https://my-app.example/api/paymaster", // your backend proxy
          context: { policyId: "my-policy" },          // provider-defined
        },
      },
    }],
  });
}

A stub-data response for EntryPoint v0.7:

{
  "sponsor": { "name": "My App" },
  "paymaster": "0x...",
  "paymasterData": "0x...",
  "paymasterPostOpGasLimit": "0x..."
}

Things to know

  • Status is Review: the interface may still change before it is final.
  • Paymaster provider URLs often contain API keys. The spec recommends pointing the capability at your own backend, which proxies to the provider and can apply its own checks before sponsoring.
  • The wallet may ignore your paymaster (on service failure, or if the user picks a wallet-provided one), so apps must not assume their paymaster actually paid.
  • Wallets that display the sponsor icon must render SVGs with an <img> tag so no embedded script can run.
  • Paymaster services should reject operations they won't sponsor already at the stub-data step.

#account-abstraction #paymaster #wallet #gas-sponsorship #rpc

Details

Authors
Lukas Rosario (@lukasrosario), Dror Tirosh (@drortirosh), Wilson Cusack (@wilsoncusack), Kristof Gazso (@kristofgazso), Hazim Jumali (@hazim-j)
Status
Review
Type
Standards Track / ERC
Created
2024-04-03
Requires

Machine-readable: Markdown · JSON