Hashgraph

.NET Core Client Library for Hedera Hashgraph

Please Note: This library is very new and as we gain experience interacting with the Hedera Network any commit to this project may cause breaking changes. Please be patient as we gain the necessary experience to provide a best in class library to access the Hedera Network.

Example

The Client object orchestrates the request construction and communication with the hedera network. It requires a small amount of configuration when created. At a minimum to retrieve an account balance, the client must be configured with a Gateway. The Gateway object represents the internet network address and account for the node processing requests. The following code example illustrates retrieving an account balance for an Address:

class Program
{
    static async Task Main(string[] args)
    {                                                 // For Example:
        var gatewayUrl = args[0];                     //   2.testnet.hedera.com:50211
        var gatewayAccountNo = long.Parse(args[1]);   //   5 (gateway node 0.0.5)
        var queryAccountNo = long.Parse(args[2]);     //   2300 (account 0.0.2300)
        try
        {
            await using var client = new Client(ctx =>
            {
                ctx.Gateway = new Gateway(gatewayUrl, 0, 0, gatewayAccountNo);
            });
            var account = new Address(0, 0, queryAccountNo);
            var balance = await client.GetAccountBalanceAsync(account);
            Console.WriteLine($"Account Balance for {account.AccountNum} is {balance:#,#} tinybars.");
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex.Message);
            Console.Error.WriteLine(ex.StackTrace);
        }
    }
}

Installation

dotnet add package Hashgraph

Hashgraph requires .NET Core Version 3.x

Contributing

While we are in the process of building the preliminary infrastructure for this project, please direct any feedback, requests or questions to Hedera’s Discord .Net SDK channel.

Cloning

This project references the Hedera Protobuf project as a git submodule (currently the vNext Branch). It is recommended to include --recurse-submodules options when cloning the repository so that the *.proto files from the submodule are present when building the project:

$ git clone --recurse-submodules https://github.com/bugbytesinc/Hashgraph.git

Build Status

Build Status

Build Requirements

This project relies protobuf support found in .net core 3, previous versions of the .net core framework will not work. (At the time of this writing we are using version 3.0.100)

Visual Studio is not required to build the library, however the project references the NSec.Cryptography library, which loads the libsodium.dll library which relies upon the VC++ runtime. In order to execute tests, the Microsoft Visual C++ Redistributable must be installed on the build agent if Visual Studio is not.

License

Hashgraph is licensed under the Apache 2.0 license.