# Paymaster API

## What is a Paymaster ?

Paymasters are smart contracts designed to facilitate transaction sponsorship.&#x20;

They allow third parties to sponsor the gas fees for transactions, enabling users to interact with the blockchain without having to pay for gas themselves.&#x20;

This can be particularly useful for onboarding new users, running promotional campaigns, or supporting decentralized applications where the end-user experience is improved by abstracting away transaction costs.

## How to sponsor transactions

To authorize the sponsorship of a given contract address, you need to add it to your sponsored addressesed in the dashboard. From there, we will accept sponsoring transactions targeting this contract.

<figure><img src="https://4172304486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkhrlOGcn41UbO16bfSjm%2Fuploads%2Ft1YjzYCr9VawXsT6dLdh%2FCapture%20d%E2%80%99e%CC%81cran%202024-05-28%20a%CC%80%2012.54.45.png?alt=media&#x26;token=a330fa13-6c1d-4947-9c39-ce76190bc22d" alt=""><figcaption><p>Add a sponsored contract address</p></figcaption></figure>

{% hint style="info" %}
At the end of each month, you will receive an invoice with the total amount of gas fees covered. This fee is then billed through the payment method in your Cometh Connect account.

With Cometh Connect, there is no overhead on the price you pay. Depending on your license type, you have a max number of transactions you can sponsor each month.
{% endhint %}

Have a look at the "Gasless with Paymaster" section of the SDK documentation to see how to integrate it seamlessly.

{% content-ref url="../core-features/go-gasless" %}
[go-gasless](https://docs.cometh.io/core-features/go-gasless)
{% endcontent-ref %}

## Endpoints

{% hint style="info" %}
**We support multiple chains** for the paymaster services, you just need to modify the **chainId** and **apiKey** to your network. Here the[ list of our current supported networks.](https://docs.cometh.io/quick-start/supported-networks)
{% endhint %}

<table><thead><tr><th>URL</th><th data-hidden>Network</th></tr></thead><tbody><tr><td>https://paymaster.cometh.io/<strong>CHAIN_ID</strong>?apikey=<strong>API_KEY</strong></td><td>Arbitrum</td></tr></tbody></table>

**Example for Arbitrum Sepolia** : <https://paymaster.cometh.io/**421614**?apikey=**API\\_KEY>\*\*

## pm\_sponsorUserOperation

Submit a UserOperation to the paymaster. If approved for sponsorship, it returns the paymasterAndData along with updated gas values

**Request**

```json
{
    "jsonrpc": "2.0",
    "id": 13,
    "method": "pm_sponsorUserOperation",
    "params": [
        {
            "sender": "0x8Fb8E6461F278c1651cb0Be92f27817e7Af128D9",
            "nonce": "0x09",
            "callData": "0x7bb374280000000000000000000000004fbf9ee4b2af774d4617eab027ac2901a41a7b5f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000406661abd00000000000000000000000000000000000000000000000000000000",
            "callGasLimit": "0x0",
            "verificationGasLimit": "0x0",
            "preVerificationGas": "0x0",
            "maxFeePerGas": "0xe4e1c00",
            "maxPriorityFeePerGas": "0x7270e00",
            "signature": "0xecececececececececececececececececececececececececececececececec"
        },
        "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
    ]
}

```

**Response**

```json
{
	"jsonrpc": "2.0",
	"id": 13,
	"result": {
		"paymaster": "0xc49d6e93bB127A2FDf349FAdBD90De6853Bf40ff",
		"paymasterData": "0x0000000000000000000000000000000000000000000000000000000067108be20000000000000000000000000000000000000000000000000000000000001234bbdf2f2f5c456f14c1c72a3fb87c73a64dc8157caa5a8243213f4e0beab664335c31160514ee572b2006e78b77dee3749303d737f3ecf58b27cbeddf24120bac1c",
		"paymasterPostOpGasLimit": "0x01",
		"paymasterVerificationGasLimit": "0x0927c0",
		"hash": "0x2a079aad99c4d17456e487153e689bcedbb55707146b597172b05ab6721cf2b5",
		"signature": "0xbbdf2f2f5c456f14c1c72a3fb87c73a64dc8157caa5a8243213f4e0beab664335c31160514ee572b2006e78b77dee3749303d737f3ecf58b27cbeddf24120bac1c",
		"preVerificationGas": "0x51a257",
		"verificationGasLimit": "0x1987c",
		"callGasLimit": "0x19afb"
	}
}
```

## pm\_supportedEntryPoints

Returns an array of supported EntryPoint addresses.

**Request**

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

```

**Response**

```json
{
	"jsonrpc": "2.0",
	"id": 1,
	"result": [
		"0x0000000071727De22E5E9d8BAf0edAc6f37da032"
	]
}
```

## Routes for Sponsored Addresses

**Retrieve Sponsored Addresses**

Use the following `GET` request to obtain the list of sponsored addresses for a specific chain.

```bash
curl --request GET \
  --url 'https://paymaster.cometh.io/sponsored-address/CHAIN_ID/?apikey=APIKEY' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/9.2.0'
```

**Set Sponsored Address**

To add a new sponsored address, send a `POST` request with the target address and chain ID.

```bash
curl --request POST \
  --url 'https://paymaster.cometh.io/sponsored-address/?apisecret=API_SECRET' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/9.2.0' \
  --data '{
    "targetAddress": "0xE1e5072de1d9B120Cc33C57EbADBCD33DBC6dD62",
    "chainId": 100
}'
```

## Routes for Sponsored Chains

**Retrieve Sponsored Chains**

The following `GET` request can be used to get information about sponsored chains.

```bash
curl --request GET \
  --url 'https://paymaster.cometh.io/sponsored-chain/CHAIN_ID/?apikey=APIKEY' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/9.2.0'
```

**Set Sponsored Chain**

This route enables users to sponsor an entire chain, allowing transactions on the chain to benefit from sponsorship.

```bash
curl --request POST \
  --url 'https://paymaster.cometh.io/sponsored-chain/' \
  --header 'Content-Type: application/json' \
  --header 'apisecret: API_SECRET' \
  --data '{
    "chainId": 100
}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cometh.io/paymaster/paymaster-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
