# Sign

The endpoint plays a pivotal role in the preparation and execution of secure asset swaps on the blockchain. By providing a Quote ID and a destination address, users can initiate the signing process, resulting in the generation of the essential signature and transaction data. This signature and data package, in turn, is integral for ensuring the validity and security of asset transfers within the blockchain network.&#x20;

## Request

<table><thead><tr><th width="202.33333333333331">Body Param</th><th width="314">Description</th><th>Example</th></tr></thead><tbody><tr><td>quote_id</td><td>String(UUID) - Required<br>The id of the quote returned in <a href="quote">quote</a> endpoint</td><td>"4c707e45-7019-4b81-b875-c5eb6fe061d6"</td></tr><tr><td>destination_address</td><td>String - Required<br>It will receive the output token</td><td>"0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9"</td></tr><tr><td>sender_address</td><td>String - Optional<br>it is for DEX aggregator partners that are using their own smart contract to mediate the interaction between users and Clipper. Aggregators should use the address of the account that they will pull tokens from (i.e., the EOA user address) as opposed to the address of their deployed contract. This is an optional value on signing requests - by default, destination_address will be used.</td><td>"0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9"</td></tr><tr><td>aux_data</td><td>String(bit32) - Optional<br>It is for use the calldata swap feature, it can be set to any string and is used for identification purposes in the event logs. By default is <mark style="color:orange;"><code>0x436c697070657200000000000000000000000000000000000000000000000000</code></mark> that is the representation of <mark style="color:orange;"><code>Clipper</code></mark></td><td> "0x31494e4348000000000000000000000000000000000000000000000000000000"</td></tr><tr><td>calldata</td><td>Bool - Optional<br>Send this as true if we want to get the bytes representation of the swap in the response. Client can use this to be sent directly to the pool contract for execution.<br>Default is <mark style="color:orange;"><code>false</code></mark></td><td>true</td></tr><tr><td>native_input</td><td>Bool - Optional<br>If the input token is native (e.g. raw ETH), this value must be true. This will use the <code>sellEthForToken</code> contract function and will take the msg.value for the input. e.g <mark style="color:orange;"><code>ETH -> USDC</code></mark><br>Default is <mark style="color:orange;"><code>false</code></mark><br>This field is mutually exclusive with <mark style="color:orange;"><code>native_output</code></mark></td><td>true</td></tr><tr><td>native_output</td><td>Bool - Optional<br>If the output token is native (i.e. raw ETH), this value must be true. This will use the <code>sellTokenForEth</code> contract function. e.g <mark style="color:orange;"><code>USDC -> ETH</code></mark><br>Default is <mark style="color:orange;"><code>false</code></mark><br>This field is mutually exclusive with <mark style="color:orange;"><code>native_input</code></mark></td><td>true</td></tr></tbody></table>

{% hint style="info" %}
In case that you want to deal with raw ETH or MATIC for input or output on the swap you should use <mark style="color:orange;">`native_input`</mark> and <mark style="color:orange;">`native_output`</mark> params. More details about Native Tokens can be found [here](https://docs.clipper.exchange/disclaimers-and-technical/guides/interacting-with-the-clipper-exchange-contracts#handling-native-currency).
{% endhint %}

## Response

Sign object

<table><thead><tr><th width="255">Field</th><th>Description</th></tr></thead><tbody><tr><td>chain_id</td><td>Integer - Represents the ID of the chain</td></tr><tr><td>input_asset_address</td><td>String - Contract address of the asset you want to provide for the swap</td></tr><tr><td>output_asset_address</td><td>String - Contract address of the asset you want to receive in the swap</td></tr><tr><td>input_amount</td><td>String - Amount of assets to be exchanged</td></tr><tr><td>output_amount</td><td>String - Amount of assets you will receive in the exchange</td></tr><tr><td>good_until</td><td>String - Number of seconds that quotes live. It can also contained a packed representation of the state</td></tr><tr><td>destination_address</td><td>String - Address will receive the output token</td></tr><tr><td>signature</td><td>Object - A <a href="https://eips.ethereum.org/EIPS/eip-2098">EIP 2098 "short signature" representation</a> for the signature from the Clipper Exchange server</td></tr><tr><td>clipper_exchange_address</td><td>String - Clipper contract address of the pool, is the address used when executing a transaction</td></tr><tr><td>calldata</td><td>String - Bytes representation of the swap function and parameters to be sent directly to the <mark style="color:orange;">clipper_exchange_address</mark> for execution</td></tr></tbody></table>

## Examples

#### Without calldata

If you want to sign a quote and manually use the values in the response to create the transaction.

***Request***

```bash
curl -X POST "https://api.clipper.exchange/rfq/sign" \
-H "x-api-key: TzuY788jU6lOoj" \
-H "Content-Type: application/json" \
-d '{
  "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
  "quote_id": "<QUOTE_ID>"
}'
```

***Response***

```json
{
    "chain_id": 1,
    "input_asset_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "output_asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "input_amount": "10000000000000000000",
    "output_amount": "5661947917",
    "good_until": "364238673390486983853316167090878487969884185392043445686993915855904",
    "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
    "signature": {
        "v": 28,
        "r": "0xfb8599e4ef2c89b03e1ebc3067f0ba38ecea64517bafa932e5c642318ec923d9",
        "s": "0x1d3c7e38951b23bc459ac91ad668dede2a681bc4c98b915116983f4ae1dcdaa7"
    },
    "clipper_exchange_address": "0xE7b0CE0526fbE3969035a145C9e9691d4d9D216c"
}
```

#### With Calldata

1. If you want to sign a quote and get the bytes representation of the swap to be sent directly to the pool contract for execution.

***Request***

```bash
curl -X POST "https://api.clipper.exchange/rfq/sign" \
-H "x-api-key: TzuY788jU6lOoj" \
-H "Content-Type: application/json" \
-d '{
  "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
  "quote_id": "<QUOTE_ID>",
  "calldata": true,
  "aux_data": "0x31494e4348000000000000000000000000000000000000000000000000000000",
}'
```

***Response***

```json
{
    "chain_id": 1,
    "input_asset_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "output_asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "input_amount": "10000000000000000000",
    "output_amount": "5661947917",
    "good_until": "364266596581665814407146313234570973398742125152679878859837657433201",
    "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
    "signature": {
        "v": 28,
        "r": "0x762ad0475b3a7c42735686d7911f117a2ff6fca1bc3c5c75f4ee43df8da2a61b",
        "s": "0x1eceffea0a50d12566e9fa6b4d9ed826106143d321389654c3c327c648f6f3f6"
    },
    "clipper_exchange_address": "0xE7b0CE0526fbE3969035a145C9e9691d4d9D216c",
    "calldata": "0x2b651a6c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000001517a780d0000000d82eb0b930000000005f7906e00b1a2bc2ec50000006400bc6529c471000000000000000000000000960376b3f62f41e7e66809a05d1c5afdfd60a0e9000000000000000000000000000000000000000000000000000000000000001c762ad0475b3a7c42735686d7911f117a2ff6fca1bc3c5c75f4ee43df8da2a61b1eceffea0a50d12566e9fa6b4d9ed826106143d321389654c3c327c648f6f3f60000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002031494e4348000000000000000000000000000000000000000000000000000000"
}
```

2. If you want to sign a quote (using native input token) and get the bytes representation of the swap to be sent directly to the pool contract.

***Request***

```bash
curl -X POST "https://api.clipper.exchange/rfq/sign" \
-H "x-api-key: TzuY788jU6lOoj" \
-H "Content-Type: application/json" \
-d '{
  "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
  "quote_id": "<QUOTE_ID>",
  "calldata": true,
  "aux_data": "0x31494e4348000000000000000000000000000000000000000000000000000000",
  "native_input": true
}'
```

***Response***

```json
{
    "chain_id": 1,
    "input_asset_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "output_asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "input_amount": "10000000000000000000",
    "output_amount": "5661947917",
    "good_until": "364126526759930684504042968316937832960196094624343681678885719229598",
    "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
    "signature": {
        "v": 28,
        "r": "0x1a8fc0856ff121e3ba5a244ee0837cef3d6c6ea96c593decc1b9d074c74c0139",
        "s": "0x60bd1d8700fca625b58cbc4fe84c61b29bf46c9855146eda18da557ab0e079d5"
    },
    "clipper_exchange_address": "0xE7b0CE0526fbE3969035a145C9e9691d4d9D216c",
    "calldata": "0x27a9b424000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000001517a780d0000000d81968de90000000005f7911f00b1a2bc2ec50000006400bc6529c49e000000000000000000000000960376b3f62f41e7e66809a05d1c5afdfd60a0e9000000000000000000000000000000000000000000000000000000000000001c1a8fc0856ff121e3ba5a244ee0837cef3d6c6ea96c593decc1b9d074c74c013960bd1d8700fca625b58cbc4fe84c61b29bf46c9855146eda18da557ab0e079d50000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000002031494e4348000000000000000000000000000000000000000000000000000000"
}
```
