# ISelfPermit

Functionality to call permit on any EIP-2612-compliant token for use in the route

### Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#functions) <a href="#functions" id="functions"></a>

#### selfPermit[​](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#selfpermit) <a href="#selfpermit" id="selfpermit"></a>

```solidity
  function selfPermit(
    address token,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external
```

Permits this contract to spend a given token from `msg.sender`

The `owner` is always msg.sender and the `spender` is always address(this).

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#parameters)

| Name       | Type    | Description                                                                     |
| ---------- | ------- | ------------------------------------------------------------------------------- |
| `token`    | address | The address of the token spent                                                  |
| `value`    | uint256 | The amount that can be spent of token                                           |
| `deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp |
| `v`        | uint8   | Must produce valid secp256k1 signature from the holder along with `r` and `s`   |
| `r`        | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s`   |
| `s`        | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v`   |

#### selfPermitIfNecessary[​](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#selfpermitifnecessary) <a href="#selfpermitifnecessary" id="selfpermitifnecessary"></a>

```solidity
  function selfPermitIfNecessary(
    address token,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external
```

Permits this contract to spend a given token from `msg.sender`

The `owner` is always msg.sender and the `spender` is always address(this). Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#parameters-1)

| Name       | Type    | Description                                                                     |
| ---------- | ------- | ------------------------------------------------------------------------------- |
| `token`    | address | The address of the token spent                                                  |
| `value`    | uint256 | The amount that can be spent of token                                           |
| `deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp |
| `v`        | uint8   | Must produce valid secp256k1 signature from the holder along with `r` and `s`   |
| `r`        | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s`   |
| `s`        | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v`   |

#### selfPermitAllowed[​](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#selfpermitallowed) <a href="#selfpermitallowed" id="selfpermitallowed"></a>

```solidity
  function selfPermitAllowed(
    address token,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external
```

Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter

The `owner` is always msg.sender and the `spender` is always address(this)

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#parameters-2)

| Name     | Type    | Description                                                                   |
| -------- | ------- | ----------------------------------------------------------------------------- |
| `token`  | address | The address of the token spent                                                |
| `nonce`  | uint256 | The current nonce of the owner                                                |
| `expiry` | uint256 | The timestamp at which the permit is no longer valid                          |
| `v`      | uint8   | Must produce valid secp256k1 signature from the holder along with `r` and `s` |
| `r`      | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` |
| `s`      | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` |

#### selfPermitAllowedIfNecessary[​](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#selfpermitallowedifnecessary) <a href="#selfpermitallowedifnecessary" id="selfpermitallowedifnecessary"></a>

```solidity
  function selfPermitAllowedIfNecessary(
    address token,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external
```

Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter

The `owner` is always msg.sender and the `spender` is always address(this) Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed.

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/interfaces/ISelfPermit#parameters-3)

| Name     | Type    | Description                                                                   |
| -------- | ------- | ----------------------------------------------------------------------------- |
| `token`  | address | The address of the token spent                                                |
| `nonce`  | uint256 | The current nonce of the owner                                                |
| `expiry` | uint256 | The timestamp at which the permit is no longer valid                          |
| `v`      | uint8   | Must produce valid secp256k1 signature from the holder along with `r` and `s` |
| `r`      | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` |
| `s`      | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` |


---

# 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.dragonswap.app/dragonswap/resources/developer-resources/smart-contracts/dragonswapv2/periphery/interfaces/iselfpermit.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.
