# Understanding BTCpay and BTC/TOKEN on the DEx

<mark style="color:yellow;">Every pair in the “Exchanges” tab using the BTC/TOKEN or TOKEN/BTC is using the BTCpay exchange market</mark>, as Freewallet utilizes the Counterparty BTCpay function to complete these orders. \
\
\&#xNAN;***Keep in mind&#x20;**<mark style="color:red;">**this functionality is very old**</mark>**,*** [***has a bug associated with it***](https://github.com/CounterpartyXCP/cips/discussions/96) ***and is&#x20;**<mark style="color:red;">**NOT**</mark>**&#x20;the common way the Counterparty Community trades assets using Counterparty and Freewallet. Most users use*** [***Dispensers***](/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/buying-xcp-and-user-created-tokens-from-a-dispenser.md) ***and*** [***The Counterparty DEx***](/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/the-decentralized-counterparty-exchange-dex.md) ***using XCP or Token to Token trades.***

<mark style="color:red;">These orders do not function like XCP/TOKEN or TOKEN/TOKEN2 type orders</mark>. <mark style="color:yellow;">For the BTC side of the order to fill a second bitcoin broadcast and transaction must be completed and very specific steps to follow</mark>.

This process can be done by Freewallet automatically or done manually.

<figure><img src="/files/W2AVteDPHvtymBxMzOaG" alt=""><figcaption><p>The BTCpay market as seen as the default page for the Exchange Tab</p></figcaption></figure>

**Take note&#x20;**<mark style="color:red;">**a protocol bug was found recently that does NOT match any orders below 0.001 BTC**</mark>**. This has been brought to the attention of the Counterparty Community and** [**laid out in detail here**](https://github.com/CounterpartyXCP/cips/discussions/96)**.&#x20;**<mark style="color:yellow;">**Please take note of this issue right now before placing a BTC order for less than 0.001 BTC at this time.**</mark>

<mark style="color:yellow;">It is also important to note that the user in the order that is transacting BTC is required to also keep Freewallet open for the order match to occur</mark> (as well as the second Bitcoin broadcast mentioned above).

<mark style="color:red;">**Auto-BTCpay only works for using BTC if:**</mark>&#x20;

1. <mark style="color:red;">**Freewallet is OPEN and listening for order matches.**</mark>**&#x20;**<mark style="color:yellow;">**If the wallet is closed and an order match happens in which you are the buyer using BTC, no BTC will be sent and the order match will expire.**</mark>
2. <mark style="color:red;">**The order is matched within 20 blocks.**</mark>**&#x20;**<mark style="color:yellow;">**After 20 blocks have passed, the BTCpay order will expire.**</mark>

**While this feature looks as simple as the Counterparty DEx for XCP and Tokens,** **it is not for beginner or even intermediate users.**\
\ <mark style="color:yellow;">**This process is used primarily when cooperation between both parties (Seller and Buyer) agree on price and process beforehand for this trustless BTCpay process to be worth using in a serious capacity.**</mark>

The process of how you view the BTCpay exchange pairs is the same as with Counterparty DEx orders

<figure><img src="/files/W2AVteDPHvtymBxMzOaG" alt=""><figcaption><p>The BTC/TOKEN exchange pairs main page</p></figcaption></figure>

First navigate to the “Exchanges” tab in the top of Freewallet.\
\ <mark style="color:yellow;">You can browse BTCpay order markets under the BTC tab and you can also use the search bar in the top right to search for individual tokens or specific BTC/TOKEN pairs</mark>.

The process of viewing the market, setting your price and placing your order is the same as described in the [Buying and Selling Tokens on the DEx](/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/buying-and-selling-xcp-and-tokens-on-the-dex.md) except for one key difference in the settings when placing your order:

<figure><img src="/files/maN0ub4N7uWvVlskyMI2" alt=""><figcaption><p>An example buy order place for RAREAIRDROP/BTC</p></figcaption></figure>

In this example of a BTCpay buy order to Buy 1 RAREAIRDROP for 0.002 BTC, the “Expires” and “Fee” entries are identical to the inputs as seen in [Buying and Selling Tokens on the DEx](/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/buying-and-selling-xcp-and-tokens-on-the-dex.md) but the extra Auto-BTCPay option is now shown.

<mark style="color:yellow;">It is highly recommended to put this setting on “Yes – Automatically sign & broadcast BTCpay transactions".</mark>

For use of this feature in Freewallet, also orient yourself with the popup Freewallet asks to “Enable Auto BTCpay”.

<figure><img src="/files/n7m7niFFd5sI2rNmVNds" alt=""><figcaption></figcaption></figure>

The Auto-BTCpay function will only work if you enable it when this popup occurs. This function will successfully fill orders in which you are the user in the order using BTC to complete.

<figure><img src="/files/3cLzKNLlJkfeDU3cxpEz" alt=""><figcaption></figcaption></figure>

Once you finalize your order and broadcast it to the Bitcoin network, you can view your transaction information the same as any other transaction by clicking “View Transaction.”

<figure><img src="/files/ltPc7MjDnydjnN5NVZjb" alt=""><figcaption><p>Order Creation Successful popup</p></figcaption></figure>

If you selected “Yes – AutoBTCpay” during the order creation Freewallet will fill this order automatically if you and the opposite party involved followed the steps above correctly (leaving the wallet open and matching within 20 blocks).

**The process of Freewallet confirming this order and then automatically signing and broadcasting the next transaction may take some time. It is important to be patient here and to leave Freewallet open throughout this time period.**

<mark style="color:yellow;">If your order isn’t matched within a certain timeframe (exactly 20 blocks) it be cancelled automatically and the tokens (or BTC) will be returned to your wallet.</mark>

To cancel your order manually when it is still active please reference [Cancelling Exchange Orders](/freewallet.io-user-manual/freewallet-functions/cancelling-exchange-orders.md).


---

# 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://davestaxcp.gitbook.io/freewallet.io-user-manual/exploring-balances-history-exchange-and-dispensers/understanding-btcpay-and-btc-token-on-the-dex.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.
