Stratis’ C# Smart Contracts: the first smart contracts which can be deployed in C#

EDIT: The smart contracts alpha is out. Check out the release here.

There are a few blockchain platforms which give developers the option to code smart contracts in C#. However, I want to show that none of these offer true C# given that Stratis’ smart contracts will be the first to execute C# code. A C# and .NET developer has an extensive suite of tools at their disposal and Stratis’ contracts will be the first time they are available in their entirety for smart contract development.

The value for Stratis, over all other platforms, is in using C# / .NET and being able to leverage the powerful ecosystem that already exists there:

  • Using Visual Studio to develop, compile and debug the code
  • Easily decompiling CIL to C# source code
  • Strong testing frameworks that run natively inside Visual Studio
  • C# that behaves exactly as it would inside any other .NET application and thus can be audited by countless developers
  • Entire companies based around the security auditing of C# code which have produced extensive list of software tools that can scan for certain kinds of conditions in the code (essentially, Stratis could have “code scanners” which can be applied or adapted to smart contract code)
  • Well established best practices and technical tools that have been developed at corporations which can be used easily with Stratis’ contracts, and will actually MEAN something because the code will behave the way developers expect it to

I could keep going. All of these (and many, many more) are only possible when running the CIL / CLR rather than a custom Virtual Machine. So far, no-one else has gone down this road with C# smart contracts. In fact, no-one has gone down this road with any smart contract offering. Not because they don’t want to, but because they can’t. Stratis is the first.

NEO is perhaps the best known platform currently offering coding in C# for smart contracts. It is misleading to say “NEO has C# smart contracts” because NEO compiles the syntax of the language into their custom instruction set to run on their custom Virtual Machine (the NeoVM). The smart contract code that executes on the Virtual Machine is not .NET, it is NEO bytecode.

Here’s a handy guide on whether your code is real C#:

  • Does the C# code run like it would in other environments such as .NET web, console or mobile applications?
  • Hence, can C# developers audit the code knowing it’s going to behave EXACTLY as they would expect?
  • Can developers debug in Visual Studio natively?
  • Can developers use other parts of the C# ecosystem such as decompilers?

If the answer to any of these questions is no, then you’d be hard-pressed to convince someone your code is truly C#. When the smart contract code that executes on the Virtual Machine is not .NET, it is virtually impossible to guarantee that the C# code will behave in the same way as a real .NET web or console application. This means that very few developers can effectively audit what has been written.

For Stratis, the smart contract code that executes on the VM is the same code that would execute in a web or mobile or any other C# application.

(As an aside, theoretically any language that can be translated into CIL will also be supported for Stratis. This means native C# and F#, VB, and any other language where software has been written to compile to CIL will be supported for Stratis’ contracts.)

Confidence in the security of smart contracts is very important for the adoption of the technology. To this end, Stratis have ensured that auditing and testing of their contracts can be easily done by a larger group of developers than ever before. This is because their contracts can be decompiled back into the C# source code. This is SO BIG for Stratis. For every single contract, nodes can natively display the C# source for auditing, instead of just the bytecode. No-one else has this functionality yet. Even Ethereum’s Solidity compilers like Porosity are very primitive.

Stratis’ smart contracts can be developed, compiled, debugged and unit tested all in Visual Studio without any external tools. It is just .NET code running like any other .NET application: there is no need for compilation down to a different Virtual Machine / instruction set. This means that auditing of the contracts could be done by developers from a community which is quite literally millions strong.

Stratis is really setting themselves apart here. They’re already making significant strides towards getting the wider C# community involved through their partnership with C# Corner (at 3 million, it boasts the largest global community of C# developers). This is accompanied by a number of incentives such as the Stratis Development Foundation and the Stratis Academy, both of which will help Stratis’ smart contracts hit the ground running.

Special thanks go to Jordan Andrews (@codingupastorm) as well as numerous other members of the team and community. Come join us on Discord, Twitter, Reddit or the community run Telegram.