Question about how smart contracts work

In a smart contract, say there's 2 parties, each bets $10 worth of bitcoin, and bet that S&P is above 2000 by end of year. Where are those bitcoin bets stored? Like that $20 worth? Is there a new address that those coins are sent to, then somehow it auto distributes to the winner? -how does that address do it though? Is it like an auto execute?

Or does the client just read which person is the winner and not actually move the asset when an event occurs? (in such a way that if person A is the winner, the message indicates that and the counterparty reads that person as the holder of the asset?)

Bets are escrowed by the Counterparty protocol, i.e. funded until the feed is resolved or expired.


So yes, there’s a new address. 

Feed owner (or owners, if multisig makes it possible to have multiple people decide on the outcome) broadcast the result and then the protocol distributes tokens to the winner(s), less the feed fee.

You can go to blockscan.com and look for broadcasts and then examine transactions from particular feed address (examine them both on blockchain.info and blockscan.com). Or you can setup a testnet and use 3 addresses (1 feed owner and 2 addresses that bet) to simulate this and see how it works. The Wiki has some info, also this forum too (see Betting & Broadcasts section). 

Therefore it’s not an auto-execute although it could be programmed with Enhanced Smart Contracts (stuff based on the recently announced support for Serpent, currently available in develop branch when used on the testnet).

Thanks for the reply, I'm still not fully understanding though,

1) so counterparty uses a blockchain, is it its own blockchain or bitcoins?

2) If it is on the bitcoin blockchain, I imagine at least 1 satoshi has to move to record it right? Where does this satoshi come from? (or is this the case?)

3) where can I see the message section on a block that represents the asset? (on the bitcoin blockchain and/or counterparty's)

4) Is it the case when someone simply creates a market order (to buy or sell an asset) that they are making a record on the blockchain? (without it even filling?)


Thanks again for your help in advance!

I’ll give it a try.

1) Counterparty uses the Bitcoin blockchain.

2) All Counterparty features are encoded as Bitcoin transactions. So for each action you have to pay the minimum Bitcoin transaction fee.

3) I believe it’s encoded as unspent multi-sig outputs in the Bitcoin blockchain. You can check out the block explorer at http://blockscan.com

4) Yes, when you create a market order it makes a record on the Blockchain. And then the protocol matches orders…