Introducing Hive libraries for Microsoft .NET

avatar
(Edited)

Today I want to introduce you to a new Microsoft .NET library for Hive developers.

Why a .NET library?

While languages like Python or JavaScript have become very popular for web development, there are also developers out there who are unfamiliar with them. Some developers oriented towards Microsoft languages like VB.NET or C # may be frustrated at having to move away from their preferred programming language and tools like Microsoft Visual Studio.

That's why I've created easy-to-use .NET classes, exposing almost all the APIs of hived and cli_wallet, and allowing .NET developers to play with any API node.

The class library is available for both VB.NET and C# languages.

I also provide a "COM library" (aka .dll) so you will also be able to use it directly in your favorite COM-enabled Windows application like Word or Excel, ... even if you don't have Microsoft Visual Studio to develop and compile applications.

Code example

The library is really easy to use. Here a simple VB.NET code example that read the information from an account and stream the last 100 blocks from the blockchain:

Dim oHC As HttpClient = New HttpClient()
Using oHive As New CHived(oHC,"https://api.hive.blog")
   Debug.Print(ohive.get_config.ToString)
   Debug.Print(ohive.get_account_count.ToString)

   oHive.get_account("arcange")
   Debug.Print(oAccount.ToString)

   Dim oBlock As JObject
   Dim oTrans As JObject
   Dim lLastBlockID As Long 
   
   lLastBlockID = oHive.get_dynamic_global_properties().Item("last_irreversible_block_num")

   For lBlockID As Long = lLastBlockID - 100 To lLastBlockID
      oBlock = ohive.get_block(lBlockID)
      If Not oBlock.Item("transactions") Is Nothing Then
         Debug.Print(String.Format("Block {0} {1} contains {2} transactions",
            oBlock.Item("block_num"),
            oBlock.Item("timestamp").ToObject(Of DateTime),
            oBlock.Item("transactions").Count))
      End If
   Next
End Using

Here another example showing how one interacts with its wallet:

Dim oHC As HttpClient = New HttpClient()
Using oWallet As New hiveAPI.ChiveWallet(oHC,"http://my.wallet.node")
   If oWallet.is_locked Then
      oWallet.unlock("mysuperwalletpassword")
   End If

   If oWallet.list_my_accounts.Count = 0 Then
      oWallet.import_key("MY_PRIVATE_POST_KEY")
   End If

   For Each oAccount In oWallet.list_my_accounts
      Debug.Print(oAccount.Item("name"))
   Next

   ' Lets vote on a post ...
   oWallet.vote("arcange", "hiveio", "announcing-the-launch-of-hive-blockchain")
   oWallet.lock()
End Using
        

Open source

The libraries are open source and can be found on GitLab.

If you have any comments or requests, please create an issue on GitLab too. You can also contact me on Discord or Telegram


Check out my apps and services


Vote for me as a witness



0
0
0.000
33 comments
avatar

pixresteemer_incognito_angel_mini.png
Bang, I did it again... I just rehived your post!
Week 32 of my contest just started...you can now check the winners of the previous week!
!BEER
5

0
0
0.000
avatar

I’m not a programmer but that seems top-notch to me. Otherwise, I don't know if other chains also have libraries for Microsoft.NET which is actually an important framework in the business environment. If they are not blind and short-sighted they should have.

0
0
0.000
avatar

If they are not blind and short-sighted they should have.

Hence why I made this one.
Thank you for your appreciation @seckorama

0
0
0.000
avatar

this is very interesting. I will surely have a look at it. thanks you.

0
0
0.000
avatar

Congratulations @arcange! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

Your post got the highest payout of the day

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @hivebuzz:

Project Activity Update
0
0
0.000
avatar

@arcange,
I am a C# developer & due to lack of data & libraries I have moved to JavaScript. Seems I could go back! Very interesting thing. So we could have windows applications that might easy work with our PCs. Highly appreciate this work!
$tangent

Cheers~

0
0
0.000
avatar

More platforms the better :)
thank you for this.

0
0
0.000
avatar

Yes, another way to make my contribution to expanding our developer base.

0
0
0.000
avatar

Microsoft?
That's related to the guy trying to vaccinate the entire planet right now, isn't it?

0
0
0.000
avatar

Is there anything related to my work that you are trying to make me understand with your comment?

0
0
0.000
avatar

oh waw, cool, cool, that opens up new possibilities!

0
0
0.000
avatar

Welcome to the world of possibles 😉

0
0
0.000
avatar

Oh! the possibilities for making ALL of TEH sPreadsheets ;) Very cool.

0
0
0.000
avatar

Wow that's good news. It's been a while since I stopped coding something in C# and I think I have slowly evolved to other languages. But this will be a great addition to Hive. I can at least suggest this to some of my friends who are still .NET devs.

Thanks, arcange.

0
0
0.000
avatar

Absolutely, let's leave no one behind. 👍

0
0
0.000