Differences/similarities of “Bitcoin script” and “Ethereum smart contract”?

Differences/similarities of “Bitcoin script” and “Ethereum smart contract”?



Can we compare Bitcoin script and Ethereum smart contract ?


Bitcoin script


Ethereum smart contract



And if yes,



What are differences/similarities of Bitcoin script and Ethereum smart contract in sense of functionality, architecture and how to interact with blockchain?



Does Bitcoin script run on-chain (similar to Ethereum smart contracts) or they run off-chain?





As far as I've understood, the biggest difference is that Ethereum's engine is Turing-complete while Bitcoin's is not. Someone else will hopefully elaborate further.
– Lauri Peltonen
Aug 29 at 8:54




1 Answer
1



There are a couple of differences between Bitcoin scripts and Ethereum smart contracts.



BITCOIN



In bitcoin the transaction have a different format from Ethereum:



A transaction typically references previous transaction outputs as new transaction inputs and dedicates all input Bitcoin values to new outputs.



So a transaction is formed by one or more transaction input (i.e., the output of previous transactions) and one or more transaction output.



The transaction outputs specify a locking script (e.g. "only the user with the private key corresponding to address 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2 can unlock this script") that defines the condition to spend the output. Whenever the transaction output is used as input in a new transaction, it must contain an unlocking script that "solves" the locking script. Those script are specified with the bitcoin script.



So, the scripts are used in Bitcoin to validate the transaction, therefore they should be run on chain, i.e. by each full node in the network.



ETHEREUM



The transactions do not reference previous transactions, because Ethereum stores directly the world-state (In bitcoin the state corresponds to the list of unspent transaction outputs (UTXO)).



In Ethreum a transaction may trigger the execution of a smart-contract if the receiver of the message call is a contract account or it may create a contract that persists on the world state.



In Ethereum the smart-contracts can be used to write applications on top of Ethereum.



Both the execution environments of Ethereum smart contracts and Bitcoin scripts are stack-based and deterministic.



The main difference between bitcoin scripts and Ethereum smart contracts is the Turing completeness: bitcoin scripts do not have loops and neither recursion and have a language that is less expressive than a DFA (Deterministic Finite Automaton), as reported here, while the Ethereum Virtual Machine (EVM) is Turing complete (if we associate a gas limits equals to infinite).



Another major difference is the fact that the Bitcoin Script does not have a notion of state (as reported here) and all the information needed is contained in the locking and unlocking scripts. Whereas Ethereum smart contracts have contract storage that can influence the behavior of the program.



Moreover, bitcoin programs are part of the respective transactions, so, when with pruning some transactions are forgotten, also the corresponding scripts are forgotten. In Ethereum the smart contract code are persistent on the state and can be canceled only if the SELFDESTRUCT opcode is explicitly called during the execution of the smart contract.


SELFDESTRUCT





And bitcoin script is run on-chain (like smart contract) ? Or they run similar to something like Javascript in web3.js? Thanks
– sas
Aug 29 at 11:19





Yes, bitcoin script is run on-chain so that everyone can verify it was run correctly
– Henk
Aug 29 at 11:30





Hi, please see my edit, I added a premise about bitcoin's and ethereum's transaction format. Let me know if the edited version is better than the previous one, otherwise I will revert the changes.
– Briomkez
Aug 29 at 15:22






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)