原标题:How smart contracts on UnitedBitcoin are different from Ethereum? (UBTC的智能合约与以太坊的有何不同?)

原作者:Maarten Swemmer(UBTC Senior IT Manager高级IT经理)


In 2015 Ethereum was the first block chain to support (near Turing complete) smart contracts. In layman’s terms, a smart contracts is basically a small computer program that evaluates a set of logical rules (being the terms of the contract) and, based on that, can initiate transactions on a blockchain when predefined events happen. For example, they can be used to keep track of the flow of goods through a supply chain or cut out the middle men for taking / providing mortgages. Also, a common application that many new blockchain projects use, is the sale of tokens or coins through a so called ICO (initial coin offering) to pre-finance their project. In such case the smart contract often includes rules that define when the ICO itself or the project as a whole is a success and when not. In the latter case, for example, payments made could be (partially) returned automatically. In that way, the smart contract automatically executes promises made in the project’s white paper.

在2015年,以太坊是第一个支持(接近图灵完备)智能合约的区块链。通俗地说,智能合约基本上是一个小型计算机程序,用于评估一组逻辑规则(即合约条款),并据此在预定义事件发生时,可以在区块链上启动交易。例如,它可以通过供应链跟踪货物的流动,或者切断中间人直接接受/提供抵押贷款。此外,许多新的区块链项目通常应用的一个例子是,通过所谓的ICO(initial coin offering,首次代币发行)销售通证(token)或代币,以预先为其项目融资。在这种情况下,智能合约通常包含定义ICO本身或整个项目何时成功或失败的规则。例如,在后一种情况下,所支付的款项可以自动(部分地)返回。通过这种方式,智能合约自动执行项目白皮书中的承诺。

These smart contracts, or programs, are executed in a so called Virtual Machine. A virtual machine is a kind of computer inside a computer where the virtual machine provides a tightly controlled environment in which the smart contract can run safely. This ensures (apart from security for the host computer) that each contract always produces the same result on any computer that evaluates it. We wouldn’t want a contract to have different outcomes on different systems. In the case of Ethereum, it uses the Ethereum Virtual Machine (EVM).


Smart contracts for the EVM need to be written in Solidity, a special programming language, designed exclusively for creating smart contracts for EVM. Programmers that need to create smart contracts for the Ethereum blockchain need to learn to program in Solidity first. 


Instead of the EVM, UnitedBitcoin uses the so called UVM as the virtual machine of choice to run smart contracts. This is currently publicly being tested on the UB Testnet. The UVM aims to provide a number of alternative features (we consider them advantages) compared to Ethereum’s EVM. The most obvious one being the support for more common programming languages. People who want to create smart contracts now don’t need to learn Solidity. Instead they can use their favorite programming language. Languages currently supported are LUA, Kotlin, C# and Java. The UVM actually runs so called LUA bytecode. We’re able to support the other languages by providing the tools to convert the programming code into LUA bytecode.


与以太坊的EVM相比,UVM旨在提供多种替代功能(我们认为它们更具优势)。最明显的是支持更常用的编程语言。 现在想创建智能合约的人不需要学习Solidity。相反,他们可以使用自己喜欢的编程语言。UVM目前支持的语言有LUA、Kotlin、C#和Java。UVM实际上运行LUA字节码。通过提供将编程代码转换为LUA字节码的工具,我们能够支持其它语言。

If we further compare the UVM and EVM, the following differences between EVM and UVM can be observed. See the table below.



Let’s briefly explain the differences:


1. Transactions per second 每秒交易量

The number of transactions per second is dependent on the block speed / block size of the supporting chain.


2. History state 历史记录状态

By not saving history states significant storage space is saved.


3. Supported languages支持的编程语言

More languages will be supported in the future.

除了C#, Java, LUA, Kotlin,UVM将来会支持更多的编程语言。

4. Sandbox 沙盒

Through the command line a sandbox mode can be activated to enable testing of smart contracts.


5. Architecture 架构

Smart contracts on the UBTC chain rely on the Bitcoin architecture.


6. In case of execution failure执行失败的情况下

The system has a somewhat forgiving nature. If execution of a contract fails, the fee paid to execute it is returned. It’s even better to first properly test the contract in the sandbox of course.


7. Transaction model交易模型

UVM follows the UTXO model of UnitedBitcoin and Bitcoin.


8. Contract naming 合约命名

Contract names in UVM are unique. This provides benefits in certain cases.


9. Destroying a contract 销毁合约

Contracts can have a state in which they can be destroyed, after losing this state, they cannot be destroyed and will remain ‘forever’.


As you can see there are quite some differences. While some of these might be considered just of a philosophical nature, other improvements are the result of learnings from the Ethereum EVM. In future blogs we will go into more detail for some of these differences and what you can do with them.

正如你所看到的,UVM和EVM有很多不同之处。 虽然其中一些只是理念属性上的不同,但其它改进是来自吸取以太坊EVM精髓的结果。在未来的博客中,我们将详细介绍其中的一些差异以及您可以用它们做些什么。