SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Dernier (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

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