SlideShare a Scribd company logo
1 of 19
Qtum
How Qtum Makes EVM Run on the UTXO Model
Patrick Dai (Cofounder of Qtum)
18th
Feb 2017@EDCON Paris
UTXO (Unspent Transaction Outputs)
1) The basis of bitcoin transaction
2) Stateless
3) Parallelism
4) SPV
Build smart contract base on stateless UTXO
sets?
New Opcodes
Qtum Account Abstraction Layer
Three New Opcodes
1.OP_EXEC - This opcode will trigger special processing of a
transaction and will execute the EVM bytecode passed to it.
OP_EXEC is primarily used to deploy new smart contracts.
2.OP_EXEC_ASSIGN - This opcode will also trigger special
processing like OP_EXEC. This opcode is passed a contract address
and data to give the contract. It will then execute the contract’s
bytecode while passing in the given data (given as CALLERDATA in
EVM). This opcode is also used for sending money to a smart
contract.
3.OP_TXHASH - Spend the OP_EXEC_ASSIGN’s Vouts after
checking they belong to the contract trying to spend them.
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
✓<pubKey>
<pubKey>
<pubKeyHash?>
<pubKeyHash>
true
Figure 1 - Bitcoin script execution
Alan Turing
23 June 1912 – 7 June 1954
I am not impressed
How to execute smart contract immediately when
merged into the blockchain?
1) Special processing of transaction output scripts (ScriptPubKey) which contains either OP_EXEC
or OP_EXEC_ASSIGN
2) When one of these opcodes are detected in a script, it is executed by all nodes of the network
after the transaction is placed into a block as output.
3) When Qtum encounters OP_EXEC or OP_EXEC_ASSIGN it runs some initial checks, then feeds
the code and gas values to the EVM
4) Executes the code and applies changes to its state and returns execution results to Qtum core
including the regular EVM results such as gas used…
Qtum Account Abstraction Layer
Account Abstraction Layer which translates
the UTXO-based model to an account-based
interface for the EVM to use
How to Deploy and Call a Contract in
Qtum?
1) Create a new zero balance contract using OP_EXEC
2) Call the contract using OP_EXEC_ASSIGN opcode
The output script (scriptPubkey) which sends money to the contract syntax
; ( )1 the version of the VM EVM is 1
;10000 gas limit for the transaction
;100 gas price in Qtum satoshis
;0xF012 data to send the contract
;0x1452b22265803b201ac1f8bb25840cb70afe3303 address of
the contract
OP_EXEC_ASSIGN
The value to send to the contract is passed using the
Assign Funds and/or Message contract TX
Figure 2 - Assign Funds
and/or Message contract TX
Contract to Contract or to Public Key Hash Address
payment
Expected Contract Transactions List: Contract spend transactions generated by the
miner and added to a block
1) Contract spends one or more of its owned output
2) These transactions must be include in a block to be considered
valid
3) Generated by miners while verifying and executing transactions,
rather than being generated by consumers
4) No need to broadcast contract transactions on the P2P network.
Spend contract OP_EXEC_ASSIGN
transaction
Figure 3 - Spend contract OP_EXEC_ASSIGN transac
Consensus-critical Coin Picking Algorithm
• To avoid nodes picking different outputs to spend contract funds,We
designed a strict and simple consensus-critical coin picking algorithm.
• First In First Out
• Any miner/node who picks different outputs will be rejected, because
it will fail at the block verification.
Figure 4 - Qtum Block Validation
showing Expected Contract
Transaction List
Standard transaction types: Bitcoin Script
templates
Deploying a new contract to the blockchain should use an output script which looks like so:
1; the version of the VM
[Gas limit]
[Gas price]
[Contract EVM bytecode]
OP_EXEC
Sending Funds and Message to an already deployed contract on the blockchain:
1; the version of the VM
[Gas limit]
[Gas price]
[Data to send to the contract]
[contract address]
OP_EXEC_ASSIGN
Note : there are no standard transaction type which can spend either of these. This is because they can
only be spent by using the Expected Contract Transaction List, and thus these spending transactions
would not be broadcast nor valid on the P2P network.
Gas model
•gas_fee = gas_limit * gas_price
•Txfee = vin - vout
•tx_relay_fee = txfee - gas_fee
•refund = gas_fee - used_gas
Gas refund model
Figure 5 - Gas refund model
Qtum General Architecture
Figure 6 - Qtum General Architecture
SPV : Simple Payment Verification
Figure 7 - testnet and mobile smartcontract Figure 8 - Apple
Watch Wallet

More Related Content

Viewers also liked

Integração das tecnologias móveis nas sala de aula através do eTwinning
Integração das tecnologias móveis nas sala de aula através do eTwinningIntegração das tecnologias móveis nas sala de aula através do eTwinning
Integração das tecnologias móveis nas sala de aula através do eTwinningAgrupamento de Escolas da Batalha
 
Você sabe para que serve a etiqueta têxtil? (cartilha)
Você sabe para que serve a etiqueta têxtil? (cartilha)Você sabe para que serve a etiqueta têxtil? (cartilha)
Você sabe para que serve a etiqueta têxtil? (cartilha)Inmetro
 
Preguntas 3-encu-clau
Preguntas 3-encu-clauPreguntas 3-encu-clau
Preguntas 3-encu-clauDiego Solano
 
July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3Monica Sharma
 
Infokvällen 2014 power point4 feb med skolstartsdatum
Infokvällen 2014 power point4 feb med skolstartsdatumInfokvällen 2014 power point4 feb med skolstartsdatum
Infokvällen 2014 power point4 feb med skolstartsdatumAlvencio
 
Apresentacion libertagia-beta-1.9
Apresentacion libertagia-beta-1.9Apresentacion libertagia-beta-1.9
Apresentacion libertagia-beta-1.9Otoniel Benavides
 
XMPP Hands-On
XMPP Hands-OnXMPP Hands-On
XMPP Hands-Oncodebits
 
Deliverable Master Copy
Deliverable Master CopyDeliverable Master Copy
Deliverable Master CopyMatt Kelly
 
saskia_koerner_resume_2015_photo
saskia_koerner_resume_2015_photosaskia_koerner_resume_2015_photo
saskia_koerner_resume_2015_photoSaskia Koerner
 
July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3Monica Sharma
 
Creative Teams
Creative TeamsCreative Teams
Creative TeamsZul Othman
 

Viewers also liked (19)

Integração das tecnologias móveis nas sala de aula através do eTwinning
Integração das tecnologias móveis nas sala de aula através do eTwinningIntegração das tecnologias móveis nas sala de aula através do eTwinning
Integração das tecnologias móveis nas sala de aula através do eTwinning
 
5º mandamento (2)
5º mandamento (2)5º mandamento (2)
5º mandamento (2)
 
Sem3 nivel1 gomez cruz
Sem3 nivel1  gomez cruzSem3 nivel1  gomez cruz
Sem3 nivel1 gomez cruz
 
Você sabe para que serve a etiqueta têxtil? (cartilha)
Você sabe para que serve a etiqueta têxtil? (cartilha)Você sabe para que serve a etiqueta têxtil? (cartilha)
Você sabe para que serve a etiqueta têxtil? (cartilha)
 
Unionsic apres oficial 07-2016 kevinmtsen@yahoo.com.br
Unionsic apres oficial 07-2016 kevinmtsen@yahoo.com.brUnionsic apres oficial 07-2016 kevinmtsen@yahoo.com.br
Unionsic apres oficial 07-2016 kevinmtsen@yahoo.com.br
 
Preguntas 3-encu-clau
Preguntas 3-encu-clauPreguntas 3-encu-clau
Preguntas 3-encu-clau
 
July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3
 
Infokvällen 2014 power point4 feb med skolstartsdatum
Infokvällen 2014 power point4 feb med skolstartsdatumInfokvällen 2014 power point4 feb med skolstartsdatum
Infokvällen 2014 power point4 feb med skolstartsdatum
 
Apresentacion libertagia-beta-1.9
Apresentacion libertagia-beta-1.9Apresentacion libertagia-beta-1.9
Apresentacion libertagia-beta-1.9
 
XMPP Hands-On
XMPP Hands-OnXMPP Hands-On
XMPP Hands-On
 
Deliverable Master Copy
Deliverable Master CopyDeliverable Master Copy
Deliverable Master Copy
 
More Licenses, More Problems
More Licenses, More ProblemsMore Licenses, More Problems
More Licenses, More Problems
 
saskia_koerner_resume_2015_photo
saskia_koerner_resume_2015_photosaskia_koerner_resume_2015_photo
saskia_koerner_resume_2015_photo
 
Marçojardim
MarçojardimMarçojardim
Marçojardim
 
Outline Thesis
Outline ThesisOutline Thesis
Outline Thesis
 
July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3July, 2014 Vol. 18 No.3
July, 2014 Vol. 18 No.3
 
CRISPRfrancesca
CRISPRfrancescaCRISPRfrancesca
CRISPRfrancesca
 
Fendall porta stream_i
Fendall porta stream_iFendall porta stream_i
Fendall porta stream_i
 
Creative Teams
Creative TeamsCreative Teams
Creative Teams
 

Similar to Qtum How To Make EVM Run On UTXO Model - Patrick Dai

Ethereum Block Chain
Ethereum Block ChainEthereum Block Chain
Ethereum Block ChainSanatPandoh
 
Introduction to EMQ
Introduction to EMQIntroduction to EMQ
Introduction to EMQEMQ
 
EthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxEthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxWijdenBenothmen1
 
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business ApplicationsEclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business ApplicationsMatthias Zimmermann
 
IMS AKAv1 AKv2 Verizon
IMS AKAv1 AKv2 VerizonIMS AKAv1 AKv2 Verizon
IMS AKAv1 AKv2 VerizonAlok Prasad
 
Blockchain Development
Blockchain DevelopmentBlockchain Development
Blockchain Developmentpreetikumara
 
Ethereum
EthereumEthereum
EthereumV C
 
Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1KlaraOrban
 
IMS Authentication with AKAv1 and AKAv2
IMS Authentication with AKAv1 and AKAv2 IMS Authentication with AKAv1 and AKAv2
IMS Authentication with AKAv1 and AKAv2 mohammad norozzudegan
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractAll Things Open
 
Build on Streakk Chain - Blockchain
Build on Streakk Chain - BlockchainBuild on Streakk Chain - Blockchain
Build on Streakk Chain - BlockchainEarn.World
 
Building a blockchain on tendermint
Building a blockchain on tendermintBuilding a blockchain on tendermint
Building a blockchain on tendermintLviv Startup Club
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumDappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumTomoaki Sato
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Codemotion
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Codemotion
 

Similar to Qtum How To Make EVM Run On UTXO Model - Patrick Dai (20)

Ergo details
Ergo detailsErgo details
Ergo details
 
Ethereum Block Chain
Ethereum Block ChainEthereum Block Chain
Ethereum Block Chain
 
Introduction to EMQ
Introduction to EMQIntroduction to EMQ
Introduction to EMQ
 
EthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxEthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptx
 
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business ApplicationsEclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
 
IMS AKAv1 AKv2 Verizon
IMS AKAv1 AKv2 VerizonIMS AKAv1 AKv2 Verizon
IMS AKAv1 AKv2 Verizon
 
Blockchain Development
Blockchain DevelopmentBlockchain Development
Blockchain Development
 
Ethereum
EthereumEthereum
Ethereum
 
Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1Encode x NEAR: Technical Overview of NEAR 1
Encode x NEAR: Technical Overview of NEAR 1
 
Blockchain
BlockchainBlockchain
Blockchain
 
Ergo Hong Kong meetup
Ergo Hong Kong meetupErgo Hong Kong meetup
Ergo Hong Kong meetup
 
IMS Authentication with AKAv1 and AKAv2
IMS Authentication with AKAv1 and AKAv2 IMS Authentication with AKAv1 and AKAv2
IMS Authentication with AKAv1 and AKAv2
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
 
Intake 38 11
Intake 38 11Intake 38 11
Intake 38 11
 
Intake 37 12
Intake 37 12Intake 37 12
Intake 37 12
 
Build on Streakk Chain - Blockchain
Build on Streakk Chain - BlockchainBuild on Streakk Chain - Blockchain
Build on Streakk Chain - Blockchain
 
Building a blockchain on tendermint
Building a blockchain on tendermintBuilding a blockchain on tendermint
Building a blockchain on tendermint
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumDappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Qtum How To Make EVM Run On UTXO Model - Patrick Dai

  • 1. Qtum How Qtum Makes EVM Run on the UTXO Model Patrick Dai (Cofounder of Qtum) 18th Feb 2017@EDCON Paris
  • 2. UTXO (Unspent Transaction Outputs) 1) The basis of bitcoin transaction 2) Stateless 3) Parallelism 4) SPV
  • 3. Build smart contract base on stateless UTXO sets?
  • 4. New Opcodes Qtum Account Abstraction Layer
  • 5. Three New Opcodes 1.OP_EXEC - This opcode will trigger special processing of a transaction and will execute the EVM bytecode passed to it. OP_EXEC is primarily used to deploy new smart contracts. 2.OP_EXEC_ASSIGN - This opcode will also trigger special processing like OP_EXEC. This opcode is passed a contract address and data to give the contract. It will then execute the contract’s bytecode while passing in the given data (given as CALLERDATA in EVM). This opcode is also used for sending money to a smart contract. 3.OP_TXHASH - Spend the OP_EXEC_ASSIGN’s Vouts after checking they belong to the contract trying to spend them.
  • 6. <sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG <sig> ✓<pubKey> <pubKey> <pubKeyHash?> <pubKeyHash> true Figure 1 - Bitcoin script execution Alan Turing 23 June 1912 – 7 June 1954 I am not impressed
  • 7. How to execute smart contract immediately when merged into the blockchain? 1) Special processing of transaction output scripts (ScriptPubKey) which contains either OP_EXEC or OP_EXEC_ASSIGN 2) When one of these opcodes are detected in a script, it is executed by all nodes of the network after the transaction is placed into a block as output. 3) When Qtum encounters OP_EXEC or OP_EXEC_ASSIGN it runs some initial checks, then feeds the code and gas values to the EVM 4) Executes the code and applies changes to its state and returns execution results to Qtum core including the regular EVM results such as gas used…
  • 8. Qtum Account Abstraction Layer Account Abstraction Layer which translates the UTXO-based model to an account-based interface for the EVM to use
  • 9. How to Deploy and Call a Contract in Qtum? 1) Create a new zero balance contract using OP_EXEC 2) Call the contract using OP_EXEC_ASSIGN opcode The output script (scriptPubkey) which sends money to the contract syntax ; ( )1 the version of the VM EVM is 1 ;10000 gas limit for the transaction ;100 gas price in Qtum satoshis ;0xF012 data to send the contract ;0x1452b22265803b201ac1f8bb25840cb70afe3303 address of the contract OP_EXEC_ASSIGN The value to send to the contract is passed using the
  • 10. Assign Funds and/or Message contract TX Figure 2 - Assign Funds and/or Message contract TX
  • 11. Contract to Contract or to Public Key Hash Address payment Expected Contract Transactions List: Contract spend transactions generated by the miner and added to a block 1) Contract spends one or more of its owned output 2) These transactions must be include in a block to be considered valid 3) Generated by miners while verifying and executing transactions, rather than being generated by consumers 4) No need to broadcast contract transactions on the P2P network.
  • 12. Spend contract OP_EXEC_ASSIGN transaction Figure 3 - Spend contract OP_EXEC_ASSIGN transac
  • 13. Consensus-critical Coin Picking Algorithm • To avoid nodes picking different outputs to spend contract funds,We designed a strict and simple consensus-critical coin picking algorithm. • First In First Out • Any miner/node who picks different outputs will be rejected, because it will fail at the block verification.
  • 14. Figure 4 - Qtum Block Validation showing Expected Contract Transaction List
  • 15. Standard transaction types: Bitcoin Script templates Deploying a new contract to the blockchain should use an output script which looks like so: 1; the version of the VM [Gas limit] [Gas price] [Contract EVM bytecode] OP_EXEC Sending Funds and Message to an already deployed contract on the blockchain: 1; the version of the VM [Gas limit] [Gas price] [Data to send to the contract] [contract address] OP_EXEC_ASSIGN Note : there are no standard transaction type which can spend either of these. This is because they can only be spent by using the Expected Contract Transaction List, and thus these spending transactions would not be broadcast nor valid on the P2P network.
  • 16. Gas model •gas_fee = gas_limit * gas_price •Txfee = vin - vout •tx_relay_fee = txfee - gas_fee •refund = gas_fee - used_gas
  • 17. Gas refund model Figure 5 - Gas refund model
  • 18. Qtum General Architecture Figure 6 - Qtum General Architecture
  • 19. SPV : Simple Payment Verification Figure 7 - testnet and mobile smartcontract Figure 8 - Apple Watch Wallet