/Nethereum

Ethereum .Net cross platform integration library

Primary LanguageC#MIT LicenseMIT

Nethereum

Join the chat at https://gitter.im/juanfranblanco/Ethereum.RPC Documentation Status NuGet version

Nethereum is the .Net integration library for Ethereum, it allows you to interact with Ethereum clients like geth, eth or parity using RPC.

The library has very similar functionality as the Javascript Etherum Web3 RPC Client Library.

All the JSON RPC/IPC methods are implemented as they appear in new versions of the clients.

The geth client is the one that is closely supported and tested, including its management extensions for admin, personal, debugging, miner.

Interaction with contracts has been simplified for deployment, function calling, transaction and event filtering and decoding of topics.

The library has been tested in all the platforms .Net Core, Mono, Linux, iOS, Android, Raspberry PI, Xbox and of course Windows.

Issues, Requests and help

Please join the chat at: Join the chat at https://gitter.im/juanfranblanco/Ethereum.RPC

We should be able to answer there any simple queries, general comments or requests, everyone is welcome. In a similar feel free to raise any issue or pull request.

Quick installation

Here is a list of all the nuget packages, if in doubt use Nethereum.Portable as it includes all the packages embedded in one. (Apart from IPC which is windows specific).

PM > Install-Package Nethereum.Portable -Pre

Another option (if targeting netstandard 1.1) is to use the Nethereum.Web3 package. This top level package include all the dependencies for RPC, ABI and Hex.

If you have issues installing the packages make sure you have a reference to System.Runtime specific to your environment.

PM > Install-Package Nethereum.Web3 -Pre
Project Source Nuget_Package Description
Nethereum.Portable NuGet version Portable class library combining all the different libraries in one package
Nethereum.Web3 NuGet version Ethereum Web3 Class Library simplifying the interaction via RPC includes contract interaction, deployment, transaction, encoding / decoding and event filters
Nethereum.ABI NuGet version Encoding and decoding of ABI Types, functions, events of Ethereum contracts
Nethereum.RPC NuGet version Core RPC Class Library to interact via RCP with an Ethereum client
Nethereum.KeyStore NuGet version Keystore generation, encryption and decryption for Ethereum key files using the Web3 Secret Storage definition, https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
Nethereum.Hex NuGet version HexTypes for encoding and encoding String, BigInteger and different Hex helper functions
Nethereum JsonRpc IpcClient NuGet version Nethereum JsonRpc IpcClient for Windows Class Library
Nethereum.ENS NuGet version Ethereum Name service library
Nethereum.Quorum NuGet version Extension to interact with Quorum, the permissioned implementation of Ethereum supporting data privacy created by JP Morgan

Finally if you want to use IPC you will need the specific IPC Client library for Windows.

Note: Named Pipe Windows is the only IPC supported and can only be used in combination with Nethereum.Web3 - Nethereum.RPC packages. So if you are planning to use IPC use the single packages

Documentation

The documentation and guides are now in Read the docs.

Video guides

There a few video guides, which might be helpful to get started.

The code for these tutorials can be found here

Introductions

These are two videos that can take you through all the initial steps from creating a contract to deployment, one in the classic windows, visual studio environment and another in a cross platform mac and visual studio code.

Windows, Visual Studio, .Net 451 Video

This video takes you through the steps of creating the a smart contract, compile it, start a private chain and deploy it using Nethereum.

Smart contracts, private test chain and deployment to Ethereum with Nethereum

Cross platform, Visual Studio Code, .Net core Video

If you want to develop in a cross platform environment this video takes you through same steps as the Windows .Net 451 step by step guide but this time in a Mac using Visual Studio Code and .Net Core.

Cross platform development in Ethereum using .Net Core and VsCode and Nethereum

Introduction to Calls, Transactions, Events, Filters and Topics

This hands on demo provides an introduction to calls, transactions, events filters and topics

Introduction to Calls, Transactions, Events, Filters and Topics

Mappings, Structs, Arrays and complex Functions Output (DTOs)

This video provides an introduction on how to store and retrieve data from structs, mappings and arrays decoding multiple output parameters to Data Transfer Objects

Mappings, Structs, Arrays and complex Functions Output (DTOs)

Sample Projects

Nethereum Wallet

This is a cross platform wallet example using Nethereum, Xamarin.Forms and MvvmCross, targeting all main mobile platforms Android, iOS, Windows, Desktop (Windows 10 uwp), IoT with the Raspberry PI and Xbox.

Source Code

Nethereum Web

This example demonstrates using Nethereum on a web project

Source Code

Nethereum Game

This sample game demonstrates how to integrate Nethereum with the UrhoSharp SamplyGame (game sample) to create a cross-platform game that interacts with Ethereum.

A simple smart contract deployed to Ethereum allows you to tracks the users high scores and the top scores. The sample uses private keys to sign "offline" transactions and use a public node for all the communication, this way avoids the local installation of an ethereum client.

Source Code

Small video tutorial

This video gives you a quick introduction on the sample:

  • Quick overview of UrhoSharp and cross-platform development
  • Overview of public nodes like infura.io
  • Overview of private keys
  • Overview of the solution structure
  • Overview of the smart contract, .net service, offline transaction signing.

Cross platform game development with Ethereum using UrhoSharp and .Net

Nethereum Hololens

Very simple sample to demonstrate integration with Unity3d, UWP and Hololens.

Unity3d does not support (yet) the latest version of .net for scripting, but this is not an issue with UWP.

This project demonstrates how to enable this by using the Origami sample from the 101e on Holograms by Microsoft, and adding an script in which we will get the latest blockNumber.

####Video sample This video provides a quick overview of the structure, preprocessor directives and dlls necessary on the plugins folder to get this working. Hololens, Unity3d and Nethereum

Thanks and Credits

  • Many thanks to Cass for the fantastic logo (https://github.com/cassiopaia)
  • Many thanks to everyone who has submitted a request for extra features, help or bugs either here in github, gitter or other channels, you are continuously shaping this project. A big shout out specially to @slothbag, @matt.tan, @knocte, @TrekDev, @raymens, @rickzanux, @naddison36, @bobsummerwill, @brendan87, @dylanmckendry.
  • Of course everyone at Ujo, Consensys and Ethereum
  • Huge thanks to Ethan Celleti from edjCase for his great support on his JsonRpc library, NBitcoin for his implementation of the Elliptic Curve in .Net and last but not least EthereumJ, EthereumJS (and all subprojects) and Web3js for inspiration and a point of code reference and implementation to support the docs.