Zoran Skoda
smart contract

In the wide sense, one can use the definition from English wikipedia: A smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract.

The main variety are the smart contracts in the context of the distributed ledger technology and blockchain in particular.

The smart contract on the blockchain typically consists of a code written for the blockchain-supported virtual machine. The main function of the code is handling assets in a deterministic way, e.g. cryptocurrencies or other tokens, as well as triggering or controlling the operations on off-chain assets (the latter being harder to enforce). Part of the true content of the smart contract is however off-chain. Various software and other agents verify the milestones happening off-chain or trigger changes in off-chain state. Sometimes an external legal action may be necessary, thus some smart contracts contain legal prose which explains both the code contained in the manner understandable to legal system as well as various contract externalities.

Blockchain virtual machine and supported languages

In most reincarnations, the virtual machine supports a Turing complete language. In practice, there are limits on the level of complexity of the code and computer resources it may require, and the spending of resources is controlled by cryptoassets (“gas”) held by the smart contract viewed as an account on blockchain. The efficiency is important because the same code has to be executed/verified by virtually all nodes in the blockchain protocol.

Regarding that the smart contracts on blockchain by their nature are likely to often handle additional cryptographic steps, and 256-bit hashes are common in use most blockchain virtual machines (Ethereum Virtual Machine (EVM), TON Virtual Machine etc.). This is elegant but nonefficient, as 256-byte register is expensive for too small operations and does not map directly to most machines. Thus some machines pack several “bytecode” operations into a very long instruction word. Substrate project (and there are some plans by Ethereum community to go the same way) rather implements WebAssembly (Wasm) bytecode which is very efficient and the same code is used on non-blockchain platforms (emerging browser for efficient common virtual machine of web browsers!), what gives access to quality compiler, debugger and other development tools.

In all case above, higher level languages are used, which compile to the blockchain virtual machine language. For example, Solidity (introduced by Gavin Wood? in Aug 2014) is the common choice for a higher language on Ethereum blockchain, and compiles to EVM bytecode. Solidity is specially designed for blockchain use. Its design (which is intended to be Javascript-like, with some influence of C and Python; with later specific improvements/versions) is not considered very successful. Some later languages include (Python-like) Serpent and Viper. For WebAssembly, there are now compilers from C, C++, Rust, Lua, while the compiler for GoLang is in the development. Substrate blockchain project is itself mainly written in Rust, which is a relatively low level language designed for clarity and security, what makes it suitable for critical applications like blockchain. Moreover both WebAssembly is a quite well performing language, and Rust creates rather small runtime and has no need for garbage collection, the features which make them very suitable for resource expensive blockchain execution.

Tezos uses OCaml (a functional language). A major functional language on Cardano is plutus, Haskell like functional language with eager rather than laisy execution.

Accordproject develops open source framework to generate the blockchain smart contracts from source which is closer to the working needs of legal teams and is accompanied with careful creation protocols and sufficient legal prose to make the off-chain effects legally enforceable.

Hyperledger Fabric supports smart contracts in Go programming language and in Javascript. Hyperledger Sawtooth allows adding new language frameworks and it included Rust in December 2018.

Scilla, short for Smart Contract Intermediate-Level Language, is an intermediate-level smart contract language being developed for Zilliqa. Scilla has been designed as a principled language with smart contract safety in mind”…“developed hand-in-hand with formalization of its semantics and its embedding into the Coq proof assistant.”

Durov has recently designed a Forth-like stack based efficient language Fift for low level access and debugging to TON VM.

Literature

In this position paper, we consider some foundational topics regarding smart contracts (such as terminology, automation, enforceability, and semantics) and define a smart contract as an automatable and enforceable agreement. We explore a simple semantic framework for smart contracts, covering both operational and non-operational aspects, and describe templates and agreements for legally-enforceable smart contracts, based on legal documents. Building upon the Ricardian Contract, we identify operational parameters in the legal documents and use these to connect legal agreements to standardised code. We also explore the design landscape, including increasing sophistication of parameters, increasing use of common standardised code, and long-term research.

  • Christopher D. Clack, Vikram A. Bakshi, Lee Braine, Smart Contract Templates: essential requirements and design options, arxiv/1612.04496

Smart Contract Templates support legally-enforceable smart contracts, using operational parameters to connect legal agreements to standardised code. In this paper, we explore the design landscape of potential formats for storage and transmission of smart legal agreements. We identify essential requirements and describe a number of key design options, from which we envisage future development of standardised formats for defining and manipulating smart legal agreements. This provides a preliminary step towards supporting industry adoption of legally-enforceable smart contracts.

  • Massimo Bartoletti, Livio Pompianu, An empirical analysis of smart contracts: platforms, applications, and design patterns, arxiv/1703.06322
  • Digital Asset, Introducing the Digital Asset Modeling Language: a powerful alternative to smart contracts for financial institutions blog 2016; for an application in healthcare see 2019 announcement
  • Jacob Eberhardt, Stefan Tai, On or off the blockchain? Insights on off-chaining computation and data, in: 6th European Conference on Service-Oriented and Cloud Computing (ESOCC2017) Springer, Oslo (2017) 3–15 doi; preprint pdf
  • Christopher D. Clack, Ciaran McGonagle, Smart Derivatives Contracts: the ISDA Master Agreement and the automation of payments and deliveries, arxiv/1904.01461
  • P. S. Anjana et al. Achieving greater concurrency in execution of smart contracts using object semantics, arxiv/1904.00358
  • C. Molina-Jimenez et al. Implementation of smart contracts using hybrid architectures with on- and off-blockchain components, arxiv/1808.00093
  • Craig Wright, Antoaneta Serguieva (nChain), Sustainable blockchain-enabled services: Smart contracts, arxiv/1806.10638

(i) a method for automated management of contracts with hierarchical conditionality structures through an hierarchy of intelligent agents and the use of hierarchical cryptographic key-pairs; (ii) a method for efficient and secure matching and transfer of smart- contract underlyings (entities) among disparate smart contracts/subcontracts; (iii) a method for producing an hierarchy of common secrets to facilitate hierarchical communication channels of increased security in the context of smart contracts/subcontracts/underlyings; and (iv) a method for building secure and optimized repositories through distributed hash tables in the context of contracts/ subcontracts/underlyings.

  • K. Christidis, M. Devetsikiotis, Blockchains and Smart Contracts for the Internet of Things, IEEE Access 4, 2292-2303 (2016) doi (open access)
  • Craig Wright (nChain), Turing complete Bitcoin script, whitepaper pdf
  • Steve Ellis, Ari Juels, Sergey Nazarov, ChainLink, a decentralized oracle network, whitepaper, 2017
  • Ethereum Alarm Clock documentation
  • How can a contract run itself at a later time?, ethereum.stackexchange

Privacy and security aspects of smart contracts

  • A. Kosba et al. Hawk: the blockchain model of cryptography and privacy-preserving smart contracts, 2016 IEEE Symposium on Security and Privacy 839–858 doi

  • A. Unterweger et al. Lessons learned from implementing a privacy-preserving smart contract in Ethereum”. 2018 9th IFIP Intern. Conf. on New Technologies, Mobility and Security (NTMS) Feb. 2018, pp. 1–5 doi

  • F. Zhang et al. Town Crier: an authenticated data feed for smart contracts pdf

  • Ekiden pdf

  • M. Bowman et al. (Hyperledger Project) Private Data Objects: an overview arxiv/1807.05686

  • Chao Li, Balaji Palanisamy, Runhua Xu, Scalable and privacy-preserving design of on/off-chain smart contracts arxiv/1902.06359

  • Guy Zyskind et al. Enigma: decentralized computation platform with guaranteed privacy, pdf enigma.co

https://blog.enigma.co/gdpr-and-enigma-were-updating-blockchain-s-privacy-policy-d245ab00da07

  • Oraclize, Encrypted queries: private data on a public blockchain, 2016 medium blog

  • Andrea Coladangelo, Smart contracts meet quantum cryptography, arxiv/1902.05214

  • Yang Xiao, Ning Zhang, Wenjing Lou, Y. Thomas Hou, Enforcing private data usage control with blockchain and attested off-chain contract execution, arxiv/1904.07275

  • Rui Yuan et al., ShadowEth: private smart contract on public blockchain Journal of Computer Science and Technology 33:3 (2018) 542–556 doi

  • Jeff Coleman, Liam Horne, Li Xuanji, Counterfactual: generalized state channels, pdf

  • J. Adler et al. Astraea: A decentralized blockchain Oracle, doi

  • Jason Teutsch (TrueBit) On decentralized oracles for data availability, 2017, pdf

  • Sourav Das, Vinay Joseph Ribeiro, Abhijeet Anand, YODA: Enabling computationally intensive contracts on blockchains with Byzantine and Selfish nodes, arxiv/1811.03265

  • Harry Kalodner et al., Arbitrum: Scalable, private smart contracts, Proc. 27th USENIX Security Symposium 2018, pdf

  • Giovanni Ciatto, Alfredo Maffi, Stefano Mariani, Andrea Omicini, Smart contracts are more than objects: pro-activeness on the blockchain, Intern. Congress on Blockchain & Appl., Blockchain 2019: Blockchain and Applications 45-53, Springer, doi; github/tenderfone-sc

  • Bruno Bernardo, Raphaël Cauderlier, Zhenlei Hu, Basile Pesin, Julien Tesson, Mi-Cho-Coq, a framework for certifying Tezos smart contracts, arxiv/1909.08671

  • Victor Zakhary, Divyakant Agrawal, Amr El Abbadi, Transactional smart contracts in blockchain systems, arxiv/1909.06494

Last revised on September 21, 2019 at 10:15:16. See the history of this page for a list of all contributions to it.