Abstract
A smart contract is a digital protocol (software code) that enables automated monitoring and executing contract’s provisions without the need for intermediaries. Blockchain technology allows implementing smart contracts through a distributed ledger, but has no reliable way of enforcing legal rules. For example, in networks such as Bitcoin, it is possible to engage in illegal activities such as money laundering and dealing in weapons. In addition, it is impossible to enforce and audit legal costs such as taxes and duties. This research has devised a plan that allows official institutions to enforce the rules and audits efficiently during automatic execution process of smart contracts. This article discusses five important challenges in applying legal rules to Blockchain: the accreditation to the contracting parties’ and the goods’ nature, collecting legal costs, enforcing territorial laws and auditing. We present “Hyper Smart Contract”, a method for regulating Blockchain-based smart contracts and assess the limitations of the current generation of smart contracts on Ethereum to ensure a proper implementation of this plan. The performance of proposed method evaluated on a motivation application.
Introduction
Information technology in the field of business is generally based on centralized structures such as client-server architecture [1]. In which each organization keeps its transactions independently through a central ledger, and if inter-organizational information needs, the information has to be exchanged. For example, in a business between two companies, invoices and certain accounts are kept separately. This traditional approach can be costly because it requires intermediaries who charge for services [2]. It cause inefficiency due to delays in the implementation of agreements and the maintenance of a large number of ledgers. In addition, it is vulnerable, because if a central system (for example, a bank) is compromised by fraud, cyber-attack, or a small error, the entire business network will be affected [1].
Smart contract is a digital abstraction model containing a ledger with associated code that enables automated monitoring and executing contract’s provisions. Blockchain permit to implement a smart contract with a distributed ledger that automatically handles the registration process of transactions and tracking assets on a business network, such as Fig. 1 [3, 4]. An asset can be tangible such as house, car, cash, and land, or intangible such as intellectual property, patents, copyrights, or trademarks. Almost such a network can tracked and traded on anything valuable, reducing the risks and the costs for the parties involved in the network [5]. Distributed ledger means that there is a decentralized database; a copy of this information (ledger) is available to all users. It increases transparency in network [6]. One of the first applications of Blockchain was Bitcoin digital currency (cryptocurrency), introduced in 2009 [7].
The smart contract abstraction model.
Today, the use of Blockchain technology goes beyond direct financial transactions (such as currency tokens) and can cover any transactions or contracts. The term “smart contract” refers to a model of contracts in which the various stages of the interactions between the parties are done in a software and automatic manner and do not require the presence of an intermediary agent for monitoring and control [8]. Blockchain technology has made the implementation of smart contracts even more decentralized in terms of software structure. Ethereum’s dedicated network1
Ethereum:
Save time: The complex transactions are fast because there is no longer need for validation by a centralized system. Cost savings: Network is responsible to monitor and control the contract; therefore, there is no need for intermediaries. High security: The use of information encryption methods and distributed ledger has greatly reduced the possibility of data manipulation. Audit Improvement: Due to the existence of a common ledger, regardless of the number of factors affecting the contract, auditing will be easier and more complete. Improve privacy: Removing intermediaries can provide more privacy protection. Flexibility: Automatic control and monitoring processes makes it easier to update and change contract processes.
Bitcoin, for example, has created a public, transparent, secure, and trustworthy ledger for digital currency interaction. The ownership of bitcoin is controlled by a corresponding smart contract [7].
Blockchain-based smart contract do not apply all controls. For example if a network is used to distribute drugs, there will be legal challenges. New researches have focused on the need to apply legal rules to the Blockchain transactions, which we briefly review in the next section.
The first challenge for applying legal rules in a Blockchain-based network is to “validate the parties involved in a contract”. In a well-known example of Blockchain, such as Bitcoin, everyone could enter and exchange money and create transactions through an address [12, 13]. Therefore, it is difficult to identify these individuals, and in most cases, it is not clear that which individual or legal entity is using that address to transfer assets or money. As a result, the legal rules such as tax payment becomes complicated and sometimes impossible. Most projects, such as Hyperledger Fabric [6] or InsurChain [14], propose a permissioned blockchain, usually, a whitelist of allowed users is defined with particular characteristics and permissions over the network operations [22]. For example, in InsurChain project, users must participate in the network with their real information and trade with awareness.
The second challenge is that if we use Blockchain for commodity trading, then “the nature of the commodity” may require legal control [12, 13]. For example, in a stationery store, the shop owner is not allowed to sell food products and is only allowed to sell stationery. How can legally control the nature of the goods? How can prevent the illegal sale of smuggled goods such as drugs and weapons? Provence, a product supply chains project, has come up with a plan for this question [15]. In this project, the manufacturer must meet the standard for the use and production of a particular product. The manufacturer submits its request for the production and, if approved by the auditors or inspectors, the standard is given. These auditors issue the relevant license by in-person visiting, and all is recorded on the network.
The third challenge is how can we calculate “law costs” such as tolls, fines and taxes in a transaction, collect them from the parties to the contract, and deposit them into legal accounts [12, 13]. To solve this problem, a few other questions arise, for example, which is the deposit account or who has control over this account? A review of various projects has not yet provided a plan for this challenge.
The fourth challenge facing Blockchain transactions is “applying the territorial laws” that vary from country to country. If we use a shared ledger, it needs for a flexible approach to territorial laws. In most projects, a fixed structure is designed to accomplish the desired goal. For example, Provence project2
The last challenge discussed in this paper is “audit,” which is generally possible by examining the details of all transactions to investigate violations and crimes. With privacy, how is it possible to extract all transactions from individuals or legal entities? For example, in Hyperledger Fabric, audit nodes can be defined for specific tasks in network, and on the other hand, it is possible to create access levels for different nodes [6]. In Provence, there are auditors or inspectors in the system, who are approved by the registrar and have a license to check the information on Blockchain [15]. InsurChain also introduces a third party to address claims that are more complex. Users will be able to upload relevant information to their claims, and an expert (auditor) will reviewed the information recorded on Blockchain [14]. In Medicalchain, such information is available to users, and if an audit such as health insurance is required, users can allow health insurance to access their health records [16].
In this section, we discussed five important challenges in applying legal rules to Blockchain, and we observed that various studies had address them. We propose in this article a prototype of an idea that can meet all the mentioned challenges.
Our proposal is based on the idea that an organization with a legal status does not need to enter directly into final contract. Rather, it can apply legal rules separately and through a simpler smart contract. We considered the title “Hyper Smart Contract” for the proposed approach. The main idea is to create the final contract with a set of several separated small contracts. For example, in the car sales contract to audit a vehicle’s traffic violations; it is sufficient to have a smart contract between police and the current owner of car. If approved, the car sales contract will go through one of the final monitoring steps.
We defined Hyper Smart Contract as a smart contract which integrates several independent smart contracts. Its code is a composition of services (or functions) of contained smart contracts and its ledger is shared that traces the status of used smart contracts, such as Fig. 2.
Hyper Smart Contract.
Hyper Smart Contract composes several separated smart contracts. Each smart contract acts independently and can take special legal responsibility. All of these smart contracts can be added or removed as needed. Let us look at a motivation application of the used car sales in Iran. Hyper Smart Contract of this example can contain five smart contracts.
Selling used cars in Iran requires several legal regulations. The identity of the seller, the buyer as well as the car itself must be verified. Two identities are considered for a car: exclusive car vehicle identification number and license plate. The opinion of a technical expert has to be obtained, which is usually in the responsibility of the car trade center or the buyer. Traffic violations must be settled, and various costs such as tolls, taxes, license plate changes, document registration, and other fees must be paid. In fact, selling used cars is done under the supervision of three regulatory bodies; car trading center, Police and National Real Estate Registration Organization [17]. There exist several in-progress projects using Blockchain for this type of applications involving government’s agencies [18, 19].
Car sales contract.
For our example, it is possible to create a smart contract involving all of participants and agencies, such as Fig. 3. In this way, we create a complex smart contract with several agencies. Sequential execution of the contract’s controls that each of which depends on an independent organization, slows down the contract execution. Each organization has its own schedule and operating conditions, and their coordination in a contract is challenging. The next problem is to trace the control status of each organization if the contract is not completed successfully. Due to the unsuccessful repetition of the contracts, an organization may repeat an activity several times for one control and without status changing.
“Car sales” Hyper Smart Contract.
For a used car sales contract, the proposed Hyper Smart Contract contains the following independent smart contracts (Fig. 4):
“Registration contract”: The seller, the buyer and the regulatory agencies must be registered. Registration is done through a real authentication process as a proof-of-existence (PoE). The regulatory legal body is National Real Estate Registration Organization. “License plate contract”: The seller’s ownership of the license plate must be verified. The seller who is verified in “Registration” contract enters into this contract as a proof-of-ownership (PoO). Police is the regulatory body. “Traffic violations contract”: The seller who has been verified in “License plate contract” enters this contract to settle related traffic violations. Police is the regulatory body. “Car ownership contract”: The seller’s ownership of the car must be verified. The seller who has been verified in “Registration contract” and “License plate contract” enters into “Car ownership contract“ as a proof-of-ownership (PoO). The regulatory body is National Real Estate Registration Organization. “Technical expert contract”: An expert must confirm The technical specifications of the car. As a result, the seller, who is verified in “Registration contract”, enters into this contract. The regulatory body is the car trading center (or expert persons who have the relevant license).
In the following, we explain a Hyper Smart Contract for car sales in a simplified way: the agreement on car price is done outside the sales contract and the amount will be paid to the seller automatically at the successful end of the contract (Fig. 5).
A simple composition code of “car Sales” Hyper Smart Contract.
“Car Sales” Hyper Smart Contract: Users (buyer and seller) are first identified through “Registration” contract. The steps of approval for “License plate”, “Car ownership”, “Technical expert” and “Traffic violations” are performed by the relevant smart contracts for the seller. The seller then announces the car price. The buyer could requests a purchase and entrusts the required amount to “Car Sales” contract. Then, first the license plate replacement operation and then the document registration is done by the relevant contracts for the buyer. Finally, the amount is transferred to the seller. The legal costs of the processes are transferred during the execution of the relevant contracts.
It is possible to apply the legal rules on a permissioned Blockchain transactions using “Car Sales” Hyper Smart Contract, while the regulatory agencies are participated only in the scope of duties and in the necessary time.
We implemented and evaluated3
We have used Ganache Blockchain simulator and Solidity language for programming.
The “Registration” smart contract is responsible for the registration of all users and their authentication process. This contract performs the five main operations as follows:
First the applicant user records his information using singup() function (any user can call this function). The regulator user of contract specifies the user type calling set_user_type() function (only the regulator can call this function). The verification of the real identity of the users is done with the help of the update_person_state() function (only National Real Estate Registration Organization has the possibility of calling the function). The user authentication query is performed using verify_user() function (all authenticated users can call the function). User permissions are also checked using modifier functions.
The license plate contract performs operations related to the registration and replacement of the license plate. It performs the four main operations as follows:
The applicant user first records the license plate information using plaque_registration() function (authenticated users can call the function). The Police user registers/confirms the license plate with the help of set_plaque() function (only Police users has the ability to call the function). Plate ownership inquiry is performed using verify_plaque() function (only authenticated users can call the function). Plate replacement operations are performed using plaque_replacement() function (only Police user can call the function).
The car ownership contract carries out operations related to National Real Estate Registration Organization. It performs the following four main operations:
The applicant user first records the car information using car_registration() function (authenticated users can call the function). The operator of National Real Estate Registration Organization registers/confirms the car with the help of set_car() function (only National Real Estate Registration Organization user can call the function). The car ownership inquiry is performed using verify_car() function (all authenticated users can call the function). The operator of National Real Estate Registration Organization performs the document registration operation with the help of car_ownership() function (only National Real Estate Registration Organization user can call the function).
The “Car Sales” Hyper Smart Contract performs the complete car sales operation. It performs two main operations as follows:
request_sell() function is the owner’s request to sell the car. The seller’s request is first checked to verify the identity of the car’s seller, the ownership of the license plate and the ownership of the car document. If all tests passed, the request with the seller’s proposed price will be registered in the Blockchain, and technical expert operations will be performed. The costs related to the contracts are also blocked in Hyper Smart Contract from the seller’s account.
request_buy() function is the buyer’s request for the registered car in Blockchain. First, it should be checked to verify the real identity of buyer. Then Hyper Smart Contract blocks the amount from the buyer’s account. The operations related to car plate and ownership replacement, plaque_replacement() and car_ownership(), are called, and if successful, the amount blocked from the buyer will be credited to the seller’s account.
In addition to automating the control and the execution processes of contracts, Blockchain-based smart contracts make it possible to eliminate intermediaries. However, it is not possible to enforce legal rules without the intervention of regulatory agents. The idea of Hyper Smart Contract is trying to maintain the benefits of smart contract automation with the presence of regulatory agents. In previous section, we outlined a number of challenges when applying the legal rules. Here we describe how Hyper Smart Contract can meet these challenges.
“Validation of the parties involved in a contract”: The registered user with the help of a public key, calls an external service belonging to National Real Estate Registration Organization, and if the information is correct, the desired address is confirmed. As a result, we make sure that we are dealing with a reputable real person as a proof-of-existence (PoE). “The nature of the commodity”: In our example (“Car Sales” contract), the ownership of the license plate and the car are verified with the help of two smart contracts. These contracts monitor the information entered by the seller under the supervision of Police and National Real Estate Registration Organization and, if approved, it will be confirmed in Blockchain as a proof-of-ownership (PoO). “Law costs”: In our example (“Car Sales” contract), the relevant legal fees such as tolls, taxes, traffic violations, document registration and license plate replacement are paid through the relevant smart contracts and at each executive stage. Of course, it should be noted that legal fees must be received from users in the form of digital currency. “Appling the territorial laws”: Hyper Smart Contract is designed based on separated contracts with different purposes. As a result, these contracts can be designed and used according to the territorial laws of each region. “Auditing”: The car sales contract has several supervisory bodies to audit and apply the rules. Each institution performs its relevant part through the relevant contract and automatically in a systematic way.
Legal rules considering in related projects
Sequential order prescribed by the consensus protocol of smart contract slows down the contract execution [20], especially in our case that these transactions is depend on different independent organizations. Coordinating these organizations in a contract is challenging because they have their own schedule and operating conditions. In our example, the car sales contract, the seller could call, in parallel, the related functions of “Traffic violations”, “Car ownership” and “Technical expert” smart contracts.
We prepared a simulation environment to compare the performance between a “single smart contract” and “Hyper Smart Contract” of our car sales contract example. We developed a client program to simulate the behavior of all users and agencies’ operators. This client program calls needed functions on related smart contracts. We consider a variable delay on users and operators actions. This user delay is simulated as a multiple of the response time of an inquiry function such as verify_user().
Figure 6 presents the speed up of “Hyper Smart Contract” for the car sales contract. The response time of Hyper Smart Contract could be more than a single smart contract because of involving several smart contracts. However, when user delay is realistic, a speed up more than 2.5 achieved.
Speed up of “Hyper Smart Contract” vs. “single smart contract” for car sales contract.
In order to use Blockchain technology in business and real transactions at public, we need methods to enforce legal rules. Hyper Smart Contract is an approach to implementing Blockchain-based legal businesses. In Table 1, we assess the responsiveness of related researches, as reviewed in section “2-Related Works”.
This study used Ethereum network to implement Hyper Smart Contract, but according to our studies, there are several technical limitation and challenges in current generation of Ethereum:
In Ethereum network, it is not possible to call an external service [21]. For example, it is not possible to obtain user identity information from a service outside of Blockchain (eg. from National Real Estate Registration Organization). For instant, we periodically update the status of Blockchain through an external system. In addition, an authenticated data feed system was proposed which acts as a bridge between smart contracts and existing web sites [20]. In Ethereum network, the programmer use the public-key of the smart contracts in hyper smart contract that needs to be transferred between different contracts manually. This increases the possibility of programming errors. It is appropriate that the next generation of Ethereum enable the definition of dependencies between contracts, without the need for programming. In Ethereum network, it is impossible to use the data structures and modifiers between different smart contracts. That is, if a data structure or modifier defined in a contract, the programmer cannot easily use that in other contracts.
Hyper Smart Contract makes enable law regulating using the current technology of smart contract. The integration of real legal organization is possible through a wrapper. This integration approach could benefit of other legal frameworks such as Internet of Agreements (IoA) [23], Proof of Existence [24], Mattereum [25] and Pavilion.io [26]. We implemented our integration approach using Ethereum. However, the idea of integrating independent contracts could adapt to the next generation of Blockchain and smart contract.
Footnotes
Conflict of interest
On behalf of all authors, the corresponding author states that there is no conflict of interest.
