Recently, I had a great conversation with Nathan Hourt, a brilliant backend developer that I love working with. We are on the same wave length. So it shouldn’t surprise you that we came to similar conclusions on an item that is often presented misleadingly in the public: The different aspects of smart contracts, Turing completeness and scriptability.
Before I start, let’s setup a glossary 📖 and clarify these terms.
This is a term used in computer-science and is called after Alan Turing - the guy that broke Enigma encryption in WW2. From wikipedia we get this
In computability theory, a system of data-manipulation rules [...] is said to be Turing-complete [..] if it can be used to simulate any Turing machine. This means that this system is able to recognize or decide other data-manipulation rule sets. Turing completeness is used as a way to express the power of such a data-manipulation rule set.
To break this down, it means that Turing-Complete languages can be used to do anything that is in the reach of a computer. Not surprising, pretty much any programming language is Turing-complete, including LaTex, Minecraft, Magic: The Gathering, CSS3, and even Super Mario World (more).
Interestingly, Bitcoin’s Script language is capable of building a dual stack push down automata and is thus capable of computing values in a system compatible with that of Godel’s logic system. While it is not a Turing machine, it is as powerful.
Scriptability - I am not sure this is a real English word - describes the ability to get a script installed on the blockchain easily. In essence, all major Smart-Contract platforms these days allow any user to deploy any contract onto their blockchain.
Ethereum contracts are written in Solidity, EOS contracts in Webassambly, and other blockchains use NodeJS or even Python to allow users to get their own scripts installed on the blockchain.
In fact, even Bitcoin allows scripting - in fact, their stack-based language for this is called Script.
Other blockchain systems do not provide Scripting capabilities, such as Hive yet they provide features that add just enough flexibility to have a growing smart-contract community there as well. In a sense, scripts would run off-chain and are fed with information that is stored (and ordered) by the blockchain.
Personally, I don’t like this term. It’s difficult to grasp what it really means and no concise definition exists. In short, everyone thinks about something else when they hear smart contracts.
To try to bring some meaning to this term that many would agree on, a smart contract provides means to take some sort of action on participants according to the terms set forth on deployment of said contract.
Usually, smart contracts are written in software language (Solidity, C++, …) and quite technical but they all have in common that the terms (what is executed under which conditions) is provided to the parties prior to them approving them.
What makes smart contracts (in particular in combination with Scriptablity) particularly dangerous are bugs and misunderstandings. For that reason, millions have been hacked or where lost as contracts apparently didn’t behave as expected. In fact, there are dozens of arguments about whether code is law or not. Just a primer on the scope of this issue:
- The DAO Hack
- Incident with non-standard ERC20 deflationary tokens
- Uniswap/Lendf.Me Hacks: Root Cause and Loss Analysis
- Ether Collateral Bug Disclosure
- Parity Multi-Sig Library Self-Destruct
- The biggest smart contract hacks in history or how to endanger up to US $2.2 billion
To make matters worse, most smart contracts are not meant of ordinary people. That’s because they are written in a non-natural language that obfuscates or at least disconnects the intend from the written.
In order to make smart contracts easier to understand, Ian Grigg developed Ricardian Contracts. Basically, these are standard smart contracts, written in computer slang, but extended by a legal document crafted by a lawyer. Unfortunately, not much is known about the applicability as they are only rarely used.
I am not a lawyer, but I can think of a practical problem with these: Source of Truth. In case of a disagreement of code and legal word, how would one tell this to the blockchain? A curt may rule that the software is wrong and needs fixing, but the software may already have executed and the funds are gone. Go after people in the real world? what was the advantage of using a blockchain then?
Room for innovation
As with all things in tech, there is some room left for innovations. In this case, I would be interested to see why people consider it a given that smart contracts are executed by the blockchain and not the user.
If you think of a smart contract like a state-machine that eats data and poops some outcome while going to some other state, why do we need the state and the outcome to be on the blockchain? A deterministic state-machine would always return identical outcome and undergo the same state transitions when provided the same input data again.