First, we create a token system that has a direct 1:1 equivalence with the fiat in question. For the purposes of this thread I'll use USD, but this can be built for any currency. The token system will work exactly the same way Bitcoin works, with a blockchain to keep track of who owns what tokens.
You can also use coloured coins for this, so the main network can handle trading of them. This has the advantage of not requiring merged mining and has the full support of the main network's hashing power.
The other thread does actually discuss this.
A $1 casino chip can always be exchanged for $1, and $1 can always be exchanged for a $1 casino chip.
If the casino didn't make money from gambling, then it wouldn't offer the service. You might pay $1 + fee for a $1 token. There might be a fee both ways.
I think having it so that it is always redeemable for $1 is better, since that becomes it's value. However, if there is a shortage of tokens, then their price will rise until they are worth $1 + fee.
A centralized organization (this part has to be centralized, there's no other way around it) will create DollarCoins and sell them for $1 each.
This would be better handled by allowing any organisation create tokens. Some would be trusted, some not. The exchange rate between them would reflect how trusted they were.
Since most end users are stupid and would be too confused by this intermediary "currency", it can be completely insulated from the end user. The end user will simply see they have "$1000" in their wallet, even though what they really have are DollarCoins, but it makes no difference, since they have equivalent value.
Assuming the central authority isn't hacked or something.
With multiple authorities, users could select one as their preferred option. The client could handle trades between (sub-)currencies too.
The decentralized exchange will have a blockchain-type system for keeping track of bids and asks. To participate on the exchange, you'll need a special piece of software that is essentially two wallets. One wallet for your Bitcoins, and one for your "dollars" (DollarCoins). When you place a bid, the network will confirm the bid only if you have the dollars to cover it. When you place an ask, the network will confirm the ask only if you have the Bitcoins to cover it.
This would mean an hour latency in trades, since you don't "have" bitcoins until 6 confirms.
Everything ideally should be on 1 blockchain so that ordering is preserved.
If coloured coins are used, then you can have a trade which is signed by both participants. If it is included in the main bitcoin chain, then it counts, otherwise, it is fully reversed.
The buyer creates an offer transaction of the form:
Input 0: (0.000001, coloured) -> signed by BTC buyer with "SIGHASH_ANYONECANPAY + SIGHASH_SINGLE"
Output 0: (10) -> "Send to buyer's address"
This transaction is invalid, so can't be submitted to the main network. However, the SIGHASH_ANYONECANPAY rule allows someone to add extra inputs to the transaction. The SIGHASH_SINGLE rule allows adding of more outputs.
Input 0: (0.000001, coloured) -> signed by BTC buyer with "SIGHASH_ANYONECANPAY + SIGHASH_SINGLE"
Input 1: (10 + fee, coloured) -> signed by BTC seller (i.e. $ buyer)
Output 0: (10) -> "Send to buyer's address"
Output 1: (0.000001, coloured) -> "Send to seller's address"
It is now a valid transaction. If the transaction makes it into the chain, then the trade occurs. It not, then it is reversed. It is atomic, it either fully works, or fully fails.
This system allows 2 people to trade. It lets a buyer post "Will buy 10BTC for $1000". However, for an exchange, you want to post "Will buy 10BTC for $1000 or market price, if lower".
Rules for the decentralized exchange client:
- The client software must contain a wallet address that can send and receive Bitcoins like any other wallet. It must also be capable of sending and receiving DollarCoins to any other wallet address that is DollarCoin-compatable. (These can be two different addresses.)
- The Bitcoin part of the wallet must be unlocked while a sell order is on the books (you must enter your password to unlock the wallet in order to place a sell order.) When the sell order is filled, or cancelled, the wallet is re-locked.
- The DollarCoin portion of the wallet must be unlocked to place a buy order. When the buy is filled or cancelled, the wallet is re-locked.
- When a buy is made, the wallet automatically sends the DollarCoins to the destination address.
- When a sell is made, the wallet automatically send the Bitcoins to the destination address.
You have no control over a client's software, all that has to happen on your block chains.