Introduction to Qtum Part 8

The technical side of UTXOs and operations on the Qtum network.

From a practical standpoint that is easy to understand, a UTXO is a bag of the smallest denomination of a cryptocurrency. For example, Satoshi is the smallest part of Bitcoin and any number of Bitcoins can be represented in Satoshis. A Satoshi is one-hundred millionth of a Bitcoin, which is just another way to say that there are one hundred million Satoshis in a Bitcoin. Similarly to that, any amount of bitcoins can be represented in Satoshis and any other cryptocurrency can be represented in the smallest denomination of that cryptocurrency just like any amount in United States Dollars can be represented as a sum of pennies. For example, $2.34 is 234 pennies.

From the technical standpoint, a UTXO is an amount in the wallet of a user when the user receives or sends funds. It is an amount and not the amount because a wallet may contain several UTXOs. It is important to note that the Bitcoin network only creates UTXOs when a transaction is occurring because that is when the Bitcoin network updates its blockchain. This is also the way how other networks, such as Qtum and Komodo, use UTXOs.

A Bitcoin wallet can be viewed as a combination of unspent amounts from previous transactions. For example, if a user has 3BTC in a wallet, these 3BTC may consist of 3 UTXOs: UTXO #1 equal to 0.5BTC, UTXO #2 equal to 0.5BTC, and UTXO #3 equal to 2BTC. Using UTXO instead of accounts allows the network to be very efficient because with UTXOs there is no need to be updating the status of a user’s wallet when there are no transactions in process.


Qtum integration with Ethereum Virtual Machine

Qtum uses UTXOs, yet it also uses the Ethereum Virtual Machine, which assumes that all value-transfer transactions are account-based and not UTXO-based. To make the UTXO-based transaction monitoring compatible with EVM, the developers of Qtum have created an account abstraction layer that makes it possible for the UTXO model to work with the EVM.

All the transactions on the Qtum network use the Bitcoin Scripting Language in exactly the same way that the Bitcoin network uses it. However, the Qtum network has three new operational codes. It has introduced the new codes because the Bitcoin network only needs to execute transaction-related scripts when uses are sending funds on the network, yet Qtum network had to accommodate the execution of smart contracts in addition to transaction processing.

The first new opcodes that Qtum has triggers special processing of transactions. The second code works similarly to the first one, but also has additional fields for information with contract addresses and data for the contract. The third new code reconciles parts of the abstraction layer.

When the Qtum network detects one of the new opcodes, it first places the information about the transaction into a block of the network and then nodes on the network begin executing the script that contains the opcodes. Because of this, the Bitcoin Script Language on the Qtum network is not so much a scripting language, but more of a way for the network to transport the data to the Ethereum Virtual Machine.

For smart-contract developers, the Ethereum Virtual Machine, the Solidity Scripting Language and the account-based transaction model are relatively easy to understand and use because Solidity is very similar to JavaScript, which is one of the most popular programming languages in the world. When working with the EVM, programmers can use functions that allow them to verify the balances of a current contract and other contracts on the Ethereum blockchain. The developers can also use functions that allow them to attach sending money to data, for example, send money to other smart contracts. It may seem that this functionality is very basic, yet applying it to a UTXO-based model is much more challenging than it may appear.


Gas on the Qtum Network

Another issue that Qtum Network faced had to do with making Bitcoin blockchain Turing complete when dealing only with transaction size, without having any data about fees paid to miners. If the data about a transaction doesn’t include any information about a fee, it means that the transaction could loop indefinitely on a network and halt the operations of the network. In this scenario, spammers could flood the network with spam transactions and overload the network, making it impossible to use. For this reason, the Qtum project uses the concept of gas as it was implemented by the Ethereum network. In this concept, performing a transaction on the network costs a certain amount of gas, which solves the issue of spam transactions and spam contracts.