# How does CP use OP\_RETURN

**URL:** <https://forums.counterparty.io/t/how-does-cp-use-op-return/1362>\
**Category:** Counterparty\
**Created:** [July 25, 2015, 7:39am UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362 "2015-07-25T07:39:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![digitsu](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@digitsu](https://forums.counterparty.io/u/digitsu)\
**Post date:** [July 25, 2015, 7:39am UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362/1 "2015-07-25T07:39:33Z")

</div>

hello, I’m investigating how CP works and I am wondering if you could either point me to the relevant documentation or a quick answer to the following:

Does CP use OP\_RETURN transactions?  
if yes, then as OP\_RETURN has no spendable OUTPUTS, then how does the miner get paid? (mining fee is the OUTPUTS minus the INPUTS.

What are the INPUT addresses used in a CP transaction? Do they contain bitcoins?

---

<div class="post-metadata">

**Author:** ![something](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/something/32/240_2.png) [@something](https://forums.counterparty.io/u/something)\
**Post date:** [July 25, 2015, 6:45pm UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362/2 "2015-07-25T18:45:10Z")

</div>

Take a look at this (if this is not enough, maybe `counterparty-lib` source):

> <https://github.com/tokenly/counterparty-spec/blob/master/spec/03-encoding.md>

---

<div class="post-metadata">

**Author:** ![digitsu](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@digitsu](https://forums.counterparty.io/u/digitsu)\
**Post date:** [July 26, 2015, 7:11am UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362/3 "2015-07-26T07:11:54Z")

</div>

Thanks, that helps a lot.

That pretty much sums up how sends are done. How are exchange orders (bids/asks) placed ? is the ‘order book’ living in the mempool only?

I remember that CP servers keeps a live copy of the orders in a local sqlite db. But do the CP servers add the orders when they are seen in the mempool or only when they have been mined? (obviously waiting until the txn is mined would be too slow for a practical order book.) But relying on mempool means CP servers need to keep track of orders replacing previous ones and parent cancelling child problems.

---

<div class="post-metadata">

**Author:** ![something](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/something/32/240_2.png) [@something](https://forums.counterparty.io/u/something)\
**Post date:** [July 26, 2015, 11:17am UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362/4 "2015-07-26T11:17:31Z")

</div>

Yeah it’s slow, ie each bid is a transaction. You can find about it on this forum if you search for “DEx” or in counterparty-lib source code. The main disadvantage is that it’s slow, the main advantage is that there’s no counterparty risk as the protocol takes funds into escrow.

Tokenly has a project Swapbot which works similar to [Shapeshift.io](http://Shapeshift.io), and that’s faster, but I am not yet familiar with the internals. I think it’s going to be good for (relatively) small trades that need to execute quickly.

Edit: forgot to add that dust amount (or more) in BTC is used to pay for each transaction, including DEx bids.

> **[CounterpartyXCP/counterparty-lib](https://github.com/CounterpartyXCP/counterparty-lib/search?utf8=%E2%9C%93&q=fee)**
>
> Counterparty Protocol Reference Implementation. Contribute to CounterpartyXCP/counterparty-lib development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![digitsu](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@digitsu](https://forums.counterparty.io/u/digitsu)\
**Post date:** [September 21, 2015, 4:48am UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362/5 "2015-09-21T04:48:31Z")

</div>

so if you can get the escrow of BTC a possibility (through some sort of shared multi-sig account where a smart contract can pay on a buyers behalf), and a metadata layer on top of the tokens, then you can basically effectively have an open bazaar like system right?

Though, I suppose the CP sqlite databases of the orders can be subpoenaed.

---

<div class="post-metadata">

**Author:** ![something](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/something/32/240_2.png) [@something](https://forums.counterparty.io/u/something)\
**Post date:** [October 31, 2015, 11:00am UTC](https://forums.counterparty.io/t/how-does-cp-use-op-return/1362/6 "2015-10-31T11:00:16Z")

</div>

Awesome idea!
