# pm_getPaymasterData

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://eth-mainnet.g.alchemy.com/v2/{apiKey}

Returns values to be used in paymaster-related fields of a signed userOperation. These values are not stubs and will be included in a signed userOperation as part of an `eth_sendUserOperation` call.

Reference: https://www.alchemy.com/docs/wallets/api-reference/gas-manager-admin-api/gas-abstraction-api-endpoints/pm-get-paymaster-data

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| userOperation | object | Yes | Partial UserOperation object (either v0.6 or v0.7, missing signature and paymasterData). |
| entryPoint | string | Yes | The EntryPoint address the request should be sent through. Must be one of the EntryPoints returned by the `supportedEntryPoints` RPC call. |
| chainId | string | Yes | The chain ID of the network the userOperation will be submitted on. |
| context | object | No | An object containing context. Must include a Gas Manager Policy Id and may include webhookData. |

## Result

**Response** (object): The response depends on the EntryPoint version used in the request.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "pm_getPaymasterData",
  "params": [
    {
      "sender": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
      "nonce": "0x2",
      "callData": "0xdeadbeef",
      "callGasLimit": "0x5208",
      "verificationGasLimit": "0x5208",
      "preVerificationGas": "0x5208",
      "maxFeePerGas": "0x1",
      "maxPriorityFeePerGas": "0x1"
    },
    "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
    "0x1",
    {
      "policyId": "69d524a7-e932-4214-8673-dcdcba31bb42"
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "paymasterAndData": "0xabc123"
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://eth-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "pm_getPaymasterData",
  "params": [
    {
      "sender": "string",
      "nonce": "string",
      "initCode": "string",
      "callData": "string",
      "callGasLimit": "string",
      "verificationGasLimit": "string",
      "preVerificationGas": "string",
      "maxFeePerGas": "string",
      "maxPriorityFeePerGas": "string",
      "eip7702Auth": {
        "chain_id": "string",
        "address": "string",
        "nonce": "string",
        "y_parity": "string",
        "r": "string",
        "s": "string"
      }
    },
    "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
    "0x1",
    {
      "policyId": "69d524a7-e932-4214-8673-dcdcba31bb42"
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'pm_getPaymasterData',
    params: [
      {
        sender: 'string',
        nonce: 'string',
        initCode: 'string',
        callData: 'string',
        callGasLimit: 'string',
        verificationGasLimit: 'string',
        preVerificationGas: 'string',
        maxFeePerGas: 'string',
        maxPriorityFeePerGas: 'string',
        eip7702Auth: {
          chain_id: 'string',
          address: 'string',
          nonce: 'string',
          y_parity: 'string',
          r: 'string',
          s: 'string'
        }
      },
      '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
      '0x1',
      {policyId: '69d524a7-e932-4214-8673-dcdcba31bb42'}
    ]
  })
};

fetch('https://eth-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "pm_getPaymasterData",
    "params": [{
            "sender": "string",
            "nonce": "string",
            "initCode": "string",
            "callData": "string",
            "callGasLimit": "string",
            "verificationGasLimit": "string",
            "preVerificationGas": "string",
            "maxFeePerGas": "string",
            "maxPriorityFeePerGas": "string",
            "eip7702Auth": {
                "chain_id": "string",
                "address": "string",
                "nonce": "string",
                "y_parity": "string",
                "r": "string",
                "s": "string"
            }
        }, "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "0x1", { "policyId": "69d524a7-e932-4214-8673-dcdcba31bb42" }]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"pm_getPaymasterData\",\n  \"params\": [\n    {\n      \"sender\": \"string\",\n      \"nonce\": \"string\",\n      \"initCode\": \"string\",\n      \"callData\": \"string\",\n      \"callGasLimit\": \"string\",\n      \"verificationGasLimit\": \"string\",\n      \"preVerificationGas\": \"string\",\n      \"maxFeePerGas\": \"string\",\n      \"maxPriorityFeePerGas\": \"string\",\n      \"eip7702Auth\": {\n        \"chain_id\": \"string\",\n        \"address\": \"string\",\n        \"nonce\": \"string\",\n        \"y_parity\": \"string\",\n        \"r\": \"string\",\n        \"s\": \"string\"\n      }\n    },\n    \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n    \"0x1\",\n    {\n      \"policyId\": \"69d524a7-e932-4214-8673-dcdcba31bb42\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://eth-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"pm_getPaymasterData\",\n  \"params\": [\n    {\n      \"sender\": \"string\",\n      \"nonce\": \"string\",\n      \"initCode\": \"string\",\n      \"callData\": \"string\",\n      \"callGasLimit\": \"string\",\n      \"verificationGasLimit\": \"string\",\n      \"preVerificationGas\": \"string\",\n      \"maxFeePerGas\": \"string\",\n      \"maxPriorityFeePerGas\": \"string\",\n      \"eip7702Auth\": {\n        \"chain_id\": \"string\",\n        \"address\": \"string\",\n        \"nonce\": \"string\",\n        \"y_parity\": \"string\",\n        \"r\": \"string\",\n        \"s\": \"string\"\n      }\n    },\n    \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n    \"0x1\",\n    {\n      \"policyId\": \"69d524a7-e932-4214-8673-dcdcba31bb42\"\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://eth-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"pm_getPaymasterData\",\n  \"params\": [\n    {\n      \"sender\": \"string\",\n      \"nonce\": \"string\",\n      \"initCode\": \"string\",\n      \"callData\": \"string\",\n      \"callGasLimit\": \"string\",\n      \"verificationGasLimit\": \"string\",\n      \"preVerificationGas\": \"string\",\n      \"maxFeePerGas\": \"string\",\n      \"maxPriorityFeePerGas\": \"string\",\n      \"eip7702Auth\": {\n        \"chain_id\": \"string\",\n        \"address\": \"string\",\n        \"nonce\": \"string\",\n        \"y_parity\": \"string\",\n        \"r\": \"string\",\n        \"s\": \"string\"\n      }\n    },\n    \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n    \"0x1\",\n    {\n      \"policyId\": \"69d524a7-e932-4214-8673-dcdcba31bb42\"\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: pm_getPaymasterData
description: Returns values to be used in paymaster-related fields of a signed userOperation. These values are not stubs and will be included in a signed userOperation as part of an `eth_sendUserOperation` call.
params:
  - name: userOperation
    description: Partial UserOperation object (either v0.6 or v0.7, missing signature and paymasterData).
    required: true
    schema:
      title: User Operation, either v0.6 or v0.7 (missing signature and paymasterData)
      oneOf:
        - title: User Operation v0.6
          type: object
          properties:
            sender:
              description: The account making the operation
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            nonce:
              description: Anti-replay parameter; used as salt for first-time account creation
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            initCode:
              description: The initCode of the account (needed if the account is not yet on-chain and needs creation)
              title: hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]*$
            callData:
              description: Encoded data for the primary function call or operation
              title: hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]*$
            callGasLimit:
              description: Gas allocated for the main execution call
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            verificationGasLimit:
              description: Gas allocated for verification
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            preVerificationGas:
              description: Gas for pre-verification execution and calldata
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            maxFeePerGas:
              description: Maximum fee per gas (EIP-1559)
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            maxPriorityFeePerGas:
              description: Max priority fee per gas (EIP-1559)
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            eip7702Auth:
              description: The authorization tuple that an EOA account delegates to in EIP-7702
              title: Eip 7702 Auth
              type: object
              properties:
                chain_id:
                  description: The chain Id of the authorization
                  title: hex encoded 64 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
                address:
                  description: The address of the authorization
                  title: hex encoded address
                  type: string
                  pattern: ^0x[0-9a-fA-F]{40}$
                nonce:
                  description: The nonce for the authorization
                  title: hex encoded 64 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
                y_parity:
                  description: Y parity of signed authorizzation tuple
                  title: hex encoded unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
                r:
                  description: R of signed authorizzation tuple
                  title: hex encoded 256 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
                s:
                  description: S of signed authorizzation tuple
                  title: hex encoded 256 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
        - title: User Operation v0.7
          type: object
          properties:
            sender:
              description: Account initiating operation
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            nonce:
              description: Account nonce or creation salt
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            callData:
              description: Data for operation call
              title: hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]*$
            callGasLimit:
              description: Gas allocated for call
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            verificationGasLimit:
              description: Gas allocated for verification
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            maxFeePerGas:
              description: Max fee per gas (EIP-1559)
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            maxPriorityFeePerGas:
              description: Priority fee per gas (EIP-1559)
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            paymaster:
              description: Paymaster contract address
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            paymasterVerificationGasLimit:
              description: The gas limit for paymaster verification.
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            factory:
              description: The account factory address (needed if and only if the account is not yet on-chain and needs to be created)
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            factoryData:
              description: Data for the account factory (only if the account factory exists)
              title: hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]*$
            preVerificationGas:
              description: The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            paymasterPostOpGasLimit:
              description: The amount of gas to allocate for the paymaster post-op code (only if a paymaster exists)
              title: hex encoded 64 bit unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
            eip7702Auth:
              description: The authorization tuple that an EOA account delegates to in EIP-7702
              title: Eip 7702 Auth
              type: object
              properties:
                chain_id:
                  description: The chain Id of the authorization
                  title: hex encoded 64 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
                address:
                  description: The address of the authorization
                  title: hex encoded address
                  type: string
                  pattern: ^0x[0-9a-fA-F]{40}$
                nonce:
                  description: The nonce for the authorization
                  title: hex encoded 64 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
                y_parity:
                  description: Y parity of signed authorizzation tuple
                  title: hex encoded unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
                r:
                  description: R of signed authorizzation tuple
                  title: hex encoded 256 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
                s:
                  description: S of signed authorizzation tuple
                  title: hex encoded 256 bit unsigned integer
                  type: string
                  pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
  - name: entryPoint
    required: true
    description: The EntryPoint address the request should be sent through. Must be one of the EntryPoints returned by the `supportedEntryPoints` RPC call.
    schema:
      type: string
      pattern: ^0[xX][0-9a-fA-F]*$
  - name: chainId
    required: true
    description: The chain ID of the network the userOperation will be submitted on.
    schema:
      type: string
      pattern: ^0[xX][0-9a-fA-F]+$
  - name: context
    description: An object containing context. Must include a Gas Manager Policy Id and may include webhookData.
    schema:
      type: object
      required:
        - policyId
      properties:
        policyId:
          oneOf:
            - type: string
              format: uuid
            - type: array
              items:
                type: string
                format: uuid
          description: The policy ID or list of policy IDs.
        webhookData:
          type: string
          description: Additional data you can include in the request, such as proof of humanity, if you have enabled custom rules in your Gas Manager policy.
        erc20Context:
          description: Erc20 context, required to enable users to pay gas with ERC-20 tokens.
          title: Context for Erc20 paymaster
          type: object
          properties:
            tokenAddress:
              description: Erc20 contract address
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            maxTokenAmount:
              description: Maximum allowed amount of value in raw token amount
              title: positive decimal number
              type: number
              minimum: 0
            permit:
              description: A 7597 typed permit
              title: hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]*$
result:
  name: Response
  description: The response depends on the EntryPoint version used in the request.
  schema:
    oneOf:
      - title: EntryPoint v0.6 Response
        type: object
        required:
          - paymasterAndData
        properties:
          paymasterAndData:
            type: string
            description: The 0x‑prefixed hex string for the user to put into the UO's paymasterAndData field.
      - title: EntryPoint v0.7 Response
        type: object
        required:
          - paymaster
          - paymasterData
        properties:
          paymaster:
            type: string
            description: The address of the paymaster.
          paymasterData:
            type: string
            description: The data for the paymaster in the userOperation.
examples:
  - name: pm_getPaymasterData example
    params:
      - name: userOperation
        value:
          sender: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd'
          nonce: '0x2'
          callData: '0xdeadbeef'
          callGasLimit: '0x5208'
          verificationGasLimit: '0x5208'
          preVerificationGas: '0x5208'
          maxFeePerGas: '0x1'
          maxPriorityFeePerGas: '0x1'
      - name: entryPoint
        value: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789'
      - name: chainId
        value: '0x1'
      - name: context
        value:
          policyId: 69d524a7-e932-4214-8673-dcdcba31bb42
    result:
      name: pm_getPaymasterData response
      value:
        paymasterAndData: '0xabc123'
```
