# API Reference

### Checking for Transaction Sponsorship <a href="#checking-for-transaction-sponsorship" id="checking-for-transaction-sponsorship"></a>

To check whether a swap is sponsorable, first send your unsigned transaction to your RPC endpoint at `https://eth.blinklabs.xyz/v1/<API_KEY>` with the following POST request

#### pm\_isSponsorable

{% code overflow="wrap" %}

```json
{
    "jsonrpc": "2.0",
    "method": "pm_isSponsorable",
    "params": [
        {
          "to": "<TX_TO_ADDRESS>",
          "from": "<TX_FROM_ADDRESS>",
          "value": "<TX_VALUE_HEX>",
          "data": "TX_DATA_HEX>",
          "gas": "<TX_GAS_LIMIT_HEX>"
        }
    ],
    "id": 1
}
```

{% endcode %}

Example request:

{% code overflow="wrap" %}

```json
{
    "jsonrpc": "2.0",
    "method": "pm_isSponsorable",
    "params": [
        {
          "to": "0xb30eC35F98ff1237EDe720D32aC2da7e52A5f56b",
          "from": "0x1234567890b4fa4756b8db7a52e4150e6c18fc2c",
          "value": "0x2386f26fc10000",
          "data": "0x095ea7b3000000000000000000000000111111125421cA6dc452d289314280a0f8842A650000000000000000000000000000000000000000000000000000000000000000",
          "gas": "0x11170"
        }
    ],
    "id": 0
}
```

{% endcode %}

Example response:

{% code overflow="wrap" %}

```json
{
    "id": 0,
    "result": {
        "sponsorable": true,
        "sponsorName": "Blink",
        "sponsorIcon": "https://framerusercontent.com/images/o61GQaQ3nRGkpdVnUD5P3HhDxx0.png",
        "sponsorWebsite": "https://blinklabs.xyz/"
    },
    "jsonrpc": "2.0"
}
```

{% endcode %}

If the response returns `true`, your transaction is sponsorable.

#### eth\_sendRawTransaction

After calling pm\_isSponsorable, send the signed transaction using the RPC method eth\_sendRawTransaction.

The only difference compared to a normal API is that you must add the query string parameter, sponsorship=true. The full URL would be:

`https://eth.blinklabs.xyz/v1/<API_KEY>?sponsorship=true`

```
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "eth_sendRawTransaction",
    "params": [
        "0x...",
     ],
}
```

Example response;

```
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": "0x..."
}
```

Provided that the same transaction data passed to pm\_isSponsorable is used in eth\_sendRawTransaction, the transaction will be sponsored.

**Notes:**

* We can setup arbitrary sponsorable criteria (e.g. whitelisted contract addresses, max sponsored transactions per user, etc...).
* We only sponsor if the transaction does not have enough funds.
* It's important that the gasLimit is not set too high compared to the gasUsed. We simulate the transaction and will return false in pm\_isSponsorable if the simulated transaction's gasLimit > 1.1 \* gasUsed.
