Page 54 - MSDN Magazine, November 2019
P. 54
BLOCKCHAIN
Programming Smart
Contracts in C#
John deVadoss, Peng Huang
Blockchain platforms have led to incredible advances in the design and development of decentralized applications and systems, and have been applied to domains ranging from crypto- currencies to enterprise supply chains. Smart contracts running on blockchain platforms are the core building block of this new wave of decentralized applications.
Smart contracts provide an execution environment for the economicandtransactionallogicthatencompasseselementsofa real-world contract, as well as execution of the terms of the con- tract. Running on massively scalable, decentralized and immutable blockchain platforms, they have the potential to reshape our eco- nomic institutions and the economic relationships and transactions that constitute these institutions.
In this article we guide you through the steps in developing, debugging and deploying your first smart contract using C#.
What Are Smart Contracts?
The term smart contract was first formalized by cryptographer Nick Szabo at the University of Washington in 1996. According to Szabo, “New institutions, and new ways to formalize the rela- tionships that make up these institutions, are now made possible by the digital revolution .... A smart contract is a set of promises, specified in digital form, including protocols within which the partiesperformonthesepromises.”
The easiest way to explain what a smart contract does is through an example. If you’ve bought a home or you know someone who has, you know there are multiple steps that make up what is often a time-consuming and tedious process. If you’re obtaining financing to close your new home, that’s another set of steps involving credit agencies, mortgage banks, escrow agencies and more. Each set of workflows and activities is fraught with potential errors, and multi- ple individuals and commercial entities are often forced to retrace the steps to finally move the buyer into their new home. Along the way, the buyer will have had to interact with a host of individuals, including the salesperson, finance broker, mortgage agent, escrow agent and lender. And, to compensate their work, various fees and commissions are added at each step of the process.
Smart contracts can automate the otherwise confusing and ardu- ous process behind a mortgage contract. A smart contract in this scenario programmatically connects the different parties involved with the mortgage transactions, allowing for a secure, compliant, and scalable process, while making the workflow convenient, frictionless and less error-prone for the individuals.
Some of the technology discussed in this article is in preview. All information is subject to change.
This article discusses:
• Blockchain platforms
• Smart contracts
• Writing a real-world smart contract
Technologies discussed:
C#, .NET Core, NEO Blockchain Toolkit for .NET, Neo Express
42 msdn magazine