How Qtum Makes Ethereum Contracts Run on the UTXO Model
Qtum is taking Bitcoin Core 0.13, integrating the Ethereum Virtual Machine, and adding an “Account Abstraction Layer” so that existing Etheruem contracts will work on Qtum with minimal changes. The exact way we are integrating the EVM is by adding new Bitcoin Script opcodes, and adding special processing conditions so that when these EVM using transactions are added to the blockchain, they are executed immediately (rather than only when attempting to be spent, as is normal).
Along with this, the account abstraction layer allows for contracts to only worry about balances and sending funds. This is a bit more complicated to explain without going into a lot of technical detail, but I’ll try. Normally in UTXO based coins (such as Bitcoin of course), you can’t just say “I want to send 20 coins to X”, you say “I want to send this 10 coin output, and this 5 coin output, and this 8 coin output to X, and also send 3 coins back to Y, which is my wallet.” This is called coin-picking, and it is one of the reasons that smart contract implementations on top of Bitcoin have been so difficult up to this point. A coin output must be either spent completely or not spent at all. What we’ve done with this account abstraction layer is make it so that smart contracts on the blockchain have something similar to a wallet. When a user (or another contract) sends coins to a contract, the code will create a standard “funding transaction”, which is spendable only by the appropriate smart contract. It would be a great burden for smart contracts to have to pick their own coins (i.e., having to write your own algorithm in Solidity), so we have added a consensus-critical coin picking algorithm which all contracts must use. So, for a contract to “send 5 coins to X”, the miner will pick contract-owned coins (using the consensus-critical coin picking algorithm), and when it has enough inputs for the value to send, it will then construct the outputs of the transaction. In this case, it would be “5 coins to X, remaining coins to sending smart contract (change output)”. This transaction is then added to the current block. It’s important to note that these transactions are not broadcast on the P2P network, they are only added by miners (and it is consensus-critical that they add them if they put the contract transaction in the block)
TL;DR; Qtum integrated the EVM onto a UTXO based blockchain, and writing contracts for this should be just as easy as Ethereum, but you get the benefits of the UTXO model. These benefits include mobile/light wallet support by SPV, a more stable model (whereas Ethereum has forked many times to fix problems with this), and compatibility with existing Bitcoin tools and protocols.