# /chainflip/broker/channel - Opening a Chainflip deposit channel

To initiate a swap through the `CHAINFLIP`or `CHAINFLIP_STREAMING`providers, a deposit channel must be opened first.

**Method:** `POST`\
**URL:** `https://api.swapkit.dev/chainflip/broker/channel`

The information needed to open a channel is included inside the `meta.chainflip`object of the `/quote`response, as in the example below. The object needs to be passed to the `/chainflip/broker/channel`endpoint, which creates a deposit channel.\
It contains a deposit address for the chain initiating the swap, where the tokens can be sent to.

```json
"meta": {
    ...
    "chainflip": {
        "sellAsset": {
            "chain": "Ethereum",
            "asset": "ETH"
        },
        "buyAsset": {
            "chain": "Bitcoin",
            "asset": "BTC"
        },
        "destinationAddress": "357a3So9CbsNfBBgFYACGvxxS6tMaDoa1P",
        "affiliateFees": [{
            "brokerAddress": "cFNwtr2mPhpUEB5AyJq38DqMKMkSdzaL9548hajN2DRTwh7Mq",
            "feeBps": 100
        }],
        "refundParameters": {
            "minPrice": "0x2c166186363d48000000000",
            "refundAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
            "retryDuration": 150
        }
    }
}
```

As an example a channel can be requested as:

{% tabs %}
{% tab title="cURL" %}

<pre class="language-sh"><code class="lang-sh"><strong>curl -X 'POST' \
</strong>  'https://api.swapkit.dev/chainflip/broker/channel' \
  -H 'Content-Type: application/json' \
  -H "x-api-key: YOUR_VARIABLE_HERE" \
  -d '{
        "sellAsset": {
            "chain": "Ethereum",
            "asset": "ETH"
        },
        "buyAsset": {
            "chain": "Bitcoin",
            "asset": "BTC"
        },
        "destinationAddress": "357a3So9CbsNfBBgFYACGvxxS6tMaDoa1P",
        "affiliateFees": [{
            "brokerAddress": "cFNwtr2mPhpUEB5AyJq38DqMKMkSdzaL9548hajN2DRTwh7Mq",
            "feeBps": 100
        }],
        "refundParameters": {
            "minPrice": "0x2c166186363d48000000000",
            "refundAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
            "retryDuration": 150
        }
    }'
</code></pre>

{% endtab %}
{% endtabs %}

The response contains a `depositAddress`which funds can be sent to.\
No approval is needed for this address in the case of ERC-20 tokens, and a memo is not needed either.

```json
{
    "depositAddress": "0xd3f189d1cab37e5dc1f920639ed13bf61132ab16",
    "channelId": "6543210-Ethereum-1933",
    "explorerUrl": "https://scan.chainflip.io/channels/6543210-Ethereum-1984"
}
```

***

Here is an example integrating a `/quote`request with opening a channel:

```javascript
async function swapThroughChainflip () {
    const request = {
      sellAsset: "SOL.SOL",
      buyAsset: "BTC.BTC",
      sellAmount: "1",
      providers: ["CHAINFLIP", "CHAINFLIP_STREAMING"],
      sourceAddress: "sol_address",
      destinationAddress: "btc_address",
      slippage: 1.5,
    };

    const quoteResponse = await fetch('https://api.swapkit.dev/quote', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'x-api-key': apiKey,
        },
        body: JSON.stringify(request),
    });

    const [chainflipRoute, chainflipStreamingRoute] = await quoteResponse.json();

    // Pick deposit channel info from quote response

    const chainflipDepositChannelParams = chainflipRoute.meta.chainflip;

    // Use params to open deposit channel

    const depositChannelResponse = await fetch('https://api.swapkit.dev/chainflip/broker/channel', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'x-api-key': apiKey,
        },
        body: JSON.stringify(chainflipDepositChannelParams),
    });

    const depositChannel = await depositChannelResponse.json();

    
    const { depositAddress, explorerUrl } = depositChannel;
    // Send funds to deposit address
    ...

}
```


---

# 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.swapkit.dev/swapkit-api-v2/chainflip-broker-channel-opening-a-chainflip-deposit-channel.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.
