Home » Articles » An Overview Of Smart Contract Scripting For Cryptocurrency Blockchains
Click Here To Hide Tor

An Overview Of Smart Contract Scripting For Cryptocurrency Blockchains

The blockchain technology offers secure means for recording information in a distributed, decentralized manner, which opened the door for using it to transfer value via cryptocurrecies. The blockchain technology utilized the concept of “smart contracts” which was coined by Nick Szabo in 1994, aiming at revolutionizing contract law and formal business practices via innovation of electronic commerce protocols between trustless parties across the internet.

What Are Smart Contracts?

A smart contract is a form of an electronic transaction protocol that is coded to execute the predesigned terms of a given contract. While omitting the need for trusted intermediary parties, a smart contract satisfies all conditions of a contract, including terms of payment, confidentiality, liens and enforcement, while also minimizing malicious, as well as unplanned accidental exceptions. Implementation of the smart contract technology can minimize fraud losses, transaction fees, arbitrations and enforcement costs.

Szabo used replicate asset registries for building smart contracts and utilized cryptographic hashing and Byzantine fault tolerant replication in contract execution process. Along a P2P network, each node will represent a title registry and escrow service that verifies transactions and exchanges of ownership, while also validating the processes handled by other nodes across the network. In 2002, Askemos deployed this approach while utilizing Scheme as the coding language for smart contracts.

Cryptocurrencies have implemented special forms of smart contracts, where money is the value exchanged. The code supporting smart contracts is a latent part of the blockchain protocol that is based on an anonymous probabilistic PoW (Proof of Work) Byzantine replication.

smart contract.png

Coding Smart Contracts For Cryptocurrency Blockchains:

Smart contracts are usually scripted on top of bitcoin’s, ethereum‘s and Nxt’s blockchains. However, they can also be implemented on other cryptocurrency blockchains including namecoin, mastercoin and others. Smart contract scripting can open the door for a myriad of innovations along the blockchain technology including proof carrying code, zero knowledge proofs and static analysis. Furthermore, smart contracts can create approaches that can make cryptocurrency transactions more efficient and secure e.g. via utilizing Merkilized Abstract Syntax Trees.

A language named “Script” is used for creating scripts and smart contracts on bitcoin’s blockchain. Script is somehow similar to Forth, as it is also a stake-based bytecode language, yet Script is designed to guarantee termination of execution. Smart contracts on Ethereum’s blockchain are written using bytecode and a virtual machine, known as ethereum’s virtual machine EVM, executes the code. EVM is designed to have a fixed word size (32 bits) which is untyped to promote simplicity. Nxt’s blockchain provides no scripting functionality, yet smart contracts can be created using Nxt’s API and Javascipt.

When studying the research done on cryptocurrency smart contracts, one can observe a wide variation in the possible scripting approaches:

Turing-incomplete scripting languages:

Bitcoin script is not designed to support looping or recursions. On the other hand, other cryptocurrency scripts, such as the ethereum script, are Turing-complete; in other words, they support looping and recursions. However, Turing-complete scripting languages lose completeness, when put into action, mainly due to the run-time bounds determined by the possible execution time and size of stack.

The Virtual Machine:

The bitcoin and ethereum protocols provide forms of low level decentralized computational model by creating distributed virtual machines. Accordingly, creating a higher level scripting language is now a possibility, e.g. ethereum’s scripting language “Solidity”. Also, the Nxt script offers a higher level API within the context of a general purpose programming language (Javascipt).

Language Transformation:

Another new approach which considers blockchain transactions as processes taking place within a wider business model, and proposes deriving them through transformation of a programming language, e.g. BPMN, or via means of finite state machines.

Scripting languages can provide many benefits including name registration, randomness, control of transactionality, anonymity and incentive alignment. The below diagram illustrates the nature of interaction between the scripting languages and the general infrastructure of the blockchain, or distributed ledger technology DLT.

scripting.PNG

It goes without saying that the infrastructure of DLT will largely influence the scripting language; however, interactions in the opposite direction are possible too. When examining the approach that provides randomness within the ethereum protocol, it can clearly be proven that using timestamps to provide randomness can yield a possible vulnerability.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Captcha: *