
On 30th July, I’m glad to attend the webinar “Percolation Framework for Loss Distribution of Smart Contract Risks”, which is organised by National University of Singapore.
Assistance Prof. Petar Jevtić from Arizona State University is invited as the webinar key speaker. Prof Jevtić’s research focus is on the modelling of risk with primary applications in Actuarial Science and Mathematical Finance. During the webinar, he shared with us his work done together with Nicolas Lanchier. Since the topic is related to Smart Contracts, in the beginning of his talk, he gave us a clear definition of Smart Contract from Nick Szabo.
For those who have been following Blockchain news, the name “Nick Szabo” should sound familiar because Nick Szabo is the computer scientist known for research in digital currency. Most importantly, although he has repeatedly denied it, people suspect that he is the bitcoin founder, Satoshi Nakamoto.

Smart Contracts
So, what is a Smart Contract?
The contract, a set of promises agreed to in a “meeting of the minds”, is the traditional way to formalise a relationship. We sign many different types of contracts in our lives, for example work contract, sale agreement, tenancy agreement, etc. Some of the major problems with the traditional contracts are drafting it takes a long time and we have to go to the hassle of hiring lawyers and detailing every term and condition of the agreement. Hence, what if the contract comes in a digital form where we can code it and then it can understand and execute its own terms?
Smart Contract, according to Nick Szabo, is first defined in 1990s as “a set of promises, specified in digital form, including protocols within which the parties perform on these promises“. So, Smart Contract is a computer program or a transaction protocol which is able to automate a good deal of the contracting process, without anyone intervening.
Since Smart Contract can map legal obligation into an automated process, Smart Contract helps us to reduce the need in trusted intermediators, enforcement cost, and fraud losses by formalising and securing relationships over computer networks.
Azure Blockchain Service (ABS)
When we talk about Smart Contract, there is one thing that we definitely have to discuss as well, i.e. the Blockchain technology. Both of them are of intense interest to businesses. The Smart Contracts are stored on blockchain. It’s extremely difficult for the blockchain system to be corrupted as it would require enormous computing power to override the whole network.

Singapore Airlines is one of those businesses that adopt the blockchain technology. In 2018, Singapore Airlines used Azure to convert customers’ airline miles into blockchain-based token which can then be spent across a network of retail partners. They are currently also evaluating Azure Blockchain Service (ABS), the new Microsoft managed service offering for blockchain.
ABS is a fully-managed ledger service in Azure announced in May 2019. With ABS, customers do not need to worry about developing and maintaining the underlying blockchain infrastructure.

There are a few things that I’d like to share regarding the ABS, even though it is still in preview now (as of July 2020).
Firstly, currently the ABS is supported only in a few regions, such as Southeast Asia, West Europe, East US, and so on, as shown in the following screenshot.

However, if we would like to capture, transform, and delivers transaction data using the Blockchain Data Service, then we have to be extra careful in choosing the region. As of July 2020, Blockchain Data Manager is only available in the East US and West Europe regions. Hence, if we choose any region outside of the two, we will not be able to access the Blockchain Data Manager, as shown in the screenshot below.

Secondly, as shared by Mark Russionovich, the Azure CTO, in his announcement of ABS, Microsoft is partnering with J.P. Morgan to make Quorum the first ledger available in the service. What is Quorum? Quorum is an Ethereum-based distributed ledger protocol with transaction/contract privacy and new consensus mechanisms.
Hence, we need to know that currently ABS supports only Quorum as the ledger protocol.
Thirdly, if we would like to have some sample codes on how to interact with the transaction nodes on the blockchain, there are a few samples available on the Azure Portal where we can refer to, as shown in the following screenshot.

Currently it takes about 10 minutes to create an ABS successfully on the Azure Portal.
Local Deployment of Smart Contracts, Problems Encountered, and GitHub Issues
With the Azure Blockchain Development Kit for Ethereum extension, we can connect to the ABS consortium from the Visual Studio Code. With the development kit, developers can easily create, connect, build, and deploy smart contracts locally.
There is a very good quick-start guide on how to do all these on Microsoft Docs, so I will not talk about it here. Instead, I will share about problems that I encounter during the development and deployment phases.
As mentioned in the Microsoft Docs, the programming language used to implement Smart Contracts are Solidity. The first problem comes from here. In the new Solidity project created by the development kit, the sample HelloBlockchain as well as the Migrations files are having some issues.

Firstly, there is an issue regarding the compiler version, as highlighted in the first line that starts with Pragma keyword in the screenshot above.
Pragma is a keyword used to enable certain compiler features or checks. As shared by Alex Beregszaszi, the Solidity Co-Lead at Ethereum Foundation, ^0.5.0 means >=0.5.0 and < 0.6.0. Thus, in order to support both 0.5.x and 0.6.x, we need to change it to >=0.5.0, as recommended on Stack Overflow.
Secondly, by default there is no SPDX license identifier in the Solidity files. What is a SPDX license? SPDX stands for Software Package Data Exchange, an open standard about the software licenses under which a software is distributed. So, why do we need SPDX here? The Solidity documentation explains it well as follows.
Trust in smart contract can be better established if their source code is available. Since making source code available always touches on legal problems with regards to copyright, the Solidity compiler encourages the use of machine-readable SPDX license identifiers. Every source file should start with a comment indicating its license…
Layout of a Solidity Source File
Hence, we need to add the SPDX license identifier at the top of Solidity files, for example
// SPDX-License-Identifier: MIT
Now, we can proceed to build and deploy the Smart Contract.

According to the Microsoft Docs, we should be able to use the Smart Contract UI provided in the Visual Studio Code to call the contract functions. However, it is not possible at all if we have deployed the Smart Contracts to the Azure.
So the third problem that I’d like to share is that, according to Cale Teeter, Microsoft SDE and Senior Software Engineer in Blockchain Engineering, currently there is “no version of the extension support Smart Contract Interaction with remote contracts (including ABS). This will only work for locally deployed contracts“. Hence, I’ve submitted a new Pull Request to Microsoft Docs to add this notice in the documentation. Pat Altimore, Microsoft Senior Content Developer, later agreed with me and was planning to remove this part of the documentation from the Microsoft Docs.

Now here comes the fourth problem. When I launched the VS Code again, I could no longer get the Smart Contract UI back even though I redeploy the Smart Contract to local instead of ABS. VS Code will simply keep showing the message “Loading dapp…”, as shown in the screenshot below.

I thus highlighted this issue on GitHub and later in a discussion with Cale Teeter, we both agree that we really need to think of supporting the Smart Contract UI page in different manner because this Smart Contract UI page is actually a react app and as Cale Teeter himself explains, “supporting the react app inside the IDE requires some IPC magic that hides too much of what is going on“.
Future Work
Currently the issues highlighted above are new. The last one was just raised about two weeks when I am writing this article. So, if you have any new findings or doubts, please always let us know on the GitHub Issues of the project.
That’s all for my journey with Azure Blockchain Service which is still in preview and very young.
By the way, Mark Russinovich did a very good introductory presentation on what blockchain is. If you are interested in blockchain and would like to have a quick overview about this cool technology, please watch the YouTube video below.