Ethereum Smart Contracts in C# - Introducing EthSharp

C# and Ethereum logos

Note: This is a little outdated — EthSharp was ultimately discontinued. However, the work has been furthered on Stratis. Learn more here.

The Ethereum development ecosystem is young. As a result, the barriers-to-entry to get started building decentralized applications on the Ethereum blockchain are high. Budding Ethereum developers are limited to using unfamiliar languages and development environments, and command-line tools for just about everything.

For enthusiasts, this isn’t a problem, but it’s a hindrance to mainstream adoption, especially considering the ridiculous pace at which developers already have to learn new frameworks to keep up. Companies that want to venture into Ethereum development have to either hire new talent or retrain their existing teams. Individuals looking to take that step and start building out their grand idea have to jump the mental hurdle of committing time to learn and understand new syntax before they can work on a prototype.

This is why I’ve created EthSharp, an organisation that plans to make Ethereum and blockchain development as easy as web development. And it starts with a new (old?) language for smart contract development.

Ethereum Smart Contracts in C#

So far we’ve made substantial progress on a C# -> EVM compiler. Check out the source code and track progress here. Please do not use it for any significant use case yet. It’s untested and unready for real-world use cases.

This is about to get really codey really quick. If you’re not a programmer, here’s what you need to know: right now, you can successfully write really basic contracts in C# that will compile to Ethereum bytecode using EthSharp.

This is what a current EthSharp contract looks like. Functionality is limited right now, but this compiles…

using EthSharp.ContractDevelopment;

public class SimpleTest : Contract
    public UInt256 StoredData { get; private set; }

    public void Increase()
        StoredData = StoredData + 1;

to this:


Feel free to compare what a similar solidity contract looks like. Importantly, you’ll notice that EthSharp subscribes to the same ABI as web3 and solidity, so you can interact with functions on EthSharp contracts just like you do with solidity.

Long Term

There is so much to write about:

  • Design decisions

  • What will the contracts look like? Accounting for block and message objects

  • Why C#?

  • Roadmap and Timeline — When will it be production ready?

Hopefully over the next couple of weeks I can talk about some of the above if the interest is there.

The end goal is to be able to write smart contracts in a familiar language, and test and deploy them all from within a known, friendly interface. Something like… Visual Studio, perhaps?

The EthSharp compiler still has a long way to go, but for growth of the ecosystem we see it as a big step in the right direction. If you are interested in using it, or want to contribute, definitely get in touch!