# Paymaster Endpoints

All paymaster endpoints follow the JSON-RPC 2.0 specification and are available at:

```text
https://api.openfort.io/rpc/{chainId}
```

Include your Openfort publishable key in the `Authorization` header:

```http
Authorization: Bearer YOUR_OPENFORT_PUBLISHABLE_KEY
```

## pm\_sponsorUserOperation

The main endpoint for gas sponsorship. It simulates the UserOperation, estimates gas limits, and returns the paymaster signature for sponsored execution.

You can optionally pass a `policyId` in the context object to use a specific [gas sponsorship policy](/docs/configuration/gas-sponsorship) with **transaction** scope. When omitted, the system automatically discovers matching **project**-scoped policies in priority order. The policy's rules and conditions are configured via the [Policy Engine](/docs/configuration/policies).

:::warning[EntryPoint v0.8 & v0.9]
The EntryPoint v0.8 & v0.9 API expects an `UnpackedUserOperation` instead of a `PackedUserOperation`. Ensure you're sending the unpacked format.
:::

:::tip[Validation]
For EntryPoint v0.8+, the paymaster will revert if the execution of the `callData` would fail. This helps catch issues before submission.
:::

### Request (EntryPoint v0.8 & v0.9)

```json
{
  "jsonrpc": "2.0",
  "method": "pm_sponsorUserOperation",
  "params": [
    {
      "sender": "0x5a6b47F4131bf1feAFA56A05573314BcF44C9149",
      "nonce": "0x845adb2c711129d4f3966735ed98a9f09fc4ce5700000000000000000000",
      "factory": "0xd703aaE79538628d27099B8c4f621bE4CCd142d5",
      "factoryData": "0xc5265d5d...",
      "callData": "0xe9ae5c53...",
      "callGasLimit": "0x0",
      "verificationGasLimit": "0x0",
      "preVerificationGas": "0x0",
      "maxFeePerGas": "0x7a5cf70d5",
      "maxPriorityFeePerGas": "0x3b9aca00",
      "paymaster": null,
      "paymasterVerificationGasLimit": null,
      "paymasterPostOpGasLimit": null,
      "paymasterData": null,
      "signature": "0xffff..."
    },
    "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
    { "policyId": "sp_your_policy_id" }
  ],
  "id": 1
}
```

### Response (EntryPoint v0.8 & v0.9)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "preVerificationGas": "0xd3e3",
    "verificationGasLimit": "0x60b01",
    "callGasLimit": "0x13880",
    "paymaster": "0xDFF7FA1077Bce740a6a212b3995990682c0Ba66d",
    "paymasterVerificationGasLimit": "0x0",
    "paymasterPostOpGasLimit": "0x0",
    "paymasterData": "0xbcd12340a2109876543210987654301098765432..."
  }
}
```

### Request (EntryPoint v0.6)

```json
{
  "jsonrpc": "2.0",
  "method": "pm_sponsorUserOperation",
  "params": [
    {
      "sender": "0xb341FEAFaF71b09089d03B7D114599f8F491EE45",
      "nonce": "0x0",
      "initCode": "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3...",
      "callData": "0x51945447...",
      "callGasLimit": "0x0",
      "verificationGasLimit": "0x0",
      "preVerificationGas": "0x0",
      "maxPriorityFeePerGas": "0x3b9aca00",
      "maxFeePerGas": "0x7a5cf70d5",
      "paymasterAndData": "0x",
      "signature": "0x00000000ffff..."
    },
    "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
    { "policyId": "sp_your_policy_id" }
  ],
  "id": 1
}
```

### Response (EntryPoint v0.6)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "paymasterAndData": "0xbcd12340a2109876543210987654301098765432...",
    "preVerificationGas": "0xdf55",
    "verificationGas": "0x52503",
    "verificationGasLimit": "0x52503",
    "callGasLimit": "0x13880"
  }
}
```

### Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `userOperation` | Yes | The UserOperation to sponsor |
| `entryPoint` | Yes | The EntryPoint contract address |
| `context` | No | Object containing optional `policyId` for transaction-scoped policies. When omitted, project-scoped policies are auto-discovered. |

***

## pm\_validateSponsorshipPolicies

Validates a UserOperation against an array of sponsorship policies and returns which policies are willing to sponsor the operation.

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "pm_validateSponsorshipPolicies",
  "params": [
    {
      "sender": "0x1234567890123456789012345678901234567890",
      "nonce": "0x1",
      "initCode": "0x",
      "callData": "0x...",
      "callGasLimit": "0x100000",
      "verificationGasLimit": "0x20000",
      "preVerificationGas": "0x10000",
      "maxFeePerGas": "0x3b9aca00",
      "maxPriorityFeePerGas": "0x3b9aca00",
      "paymasterAndData": "0x",
      "signature": "0x"
    },
    "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
    ["policy_id_1", "policy_id_2"]
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "policyId": "policy_id_1",
      "data": {
        "name": "Free Gas Week",
        "author": "Your App",
        "icon": "data:image/png;base64,...",
        "description": "Sponsoring transactions for new users during launch week."
      }
    }
  ]
}
```

### Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `userOperation` | Yes | The UserOperation to validate |
| `entryPoint` | Yes | The EntryPoint contract address |
| `policyIds` | Yes | Array of policy IDs to check |

The response includes only the policies that would sponsor the operation, along with optional metadata about each policy.

***

## pm\_supportedEntryPoints

Returns the list of EntryPoint contracts supported by the paymaster on the current chain.

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "pm_supportedEntryPoints",
  "params": [],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
    "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
    "0x433709009B8330FDa32311DF1C2AFA402eD8D009"
  ]
}
```

Use this endpoint to verify which EntryPoint versions are supported before submitting UserOperations.
