Уважаемые пользователи Голос!
Сайт доступен в режиме «чтение» до сентября 2020 года. Операции с токенами Golos, Cyber можно проводить, используя альтернативные клиенты или через эксплорер Cyberway. Подробности здесь: https://golos.io/@goloscore/operacii-s-tokenami-golos-cyber-1594822432061
С уважением, команда “Голос”
GOLOS
RU
EN
UA
arcange
8 лет назад

[Golos.NET] A Microsoft .NET library for Golos API

Let me introduce Microsoft .NET class library for Golos : Golos.NET

Not everybody is familiar with Python or JavaScript. Some Microsoft Visual Studio developers might get frustrated having to move away from their favorite programming language.

That's why I created an open source .NET class exposing all golosd and cli_wallet API.
This will give you the power to play with any RPC or WebSocket endpoint.

The library is really easy to use, check the example below.

Golos.Net is also available as a compiled COM library (aka .dll) so you will also be able to use it in your favorite COM-enabled Windows application like Word or Excel ... even if you don't have Microsoft Visual Studio to compile the code.

Example using Golos.NET with golosd

Imports Newtonsoft.Json  
Module Test    
   Public Sub Main()     
      Using oGolos As New CGolosAPI
         Debug.Print(oGolos.get_config.ToString)
         Debug.Print(oGolos.get_account_count.ToString)

         Dim arrAcct As New ArrayList

         arrAcct.Add("arcange")

         For Each oAccount In oGolos.get_accounts(arrAcct)
            Debug.Print(oAccount.ToString)
         Next

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

         For lBlockID As Long = 1 To lLastBlockID
            oBlock = oGolos.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))

               For Each oTrans In oBlock.Item("transactions")
                  Debug.Print(String.Format("Transaction is {0} operations",
                                             oTrans.Item("operations").Item(0).Item(0)))
               Next
            End If
         Next
      End Using
   End Sub

End Module 

Using Golos.NET with cli_wallet example

Using oWallet As New GolosAPI.CGolosWallet
   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 help me - you can do the same ...
   oWallet.vote("arcange", "arcange", "Golos-api-for-microsoft-net-available")
   oWallet.vote_for_witness(“arcange”,true,true)

   ' We are done. Secure lock the wallet
   oWallet.lock()

End Using

Websocket support

Golos.Net does not require running a local node. Websocket connection support has been implemented and you can connect your CGolosd object to an external seed node.

Example:

Using oGolos As New GolosAPI.CGolosd("ws://golos-seed.arcange.eu ")
    Dim lLastBlockID As Long = 
            oGolos.get_dynamic_global_properties().Item("last_irreversible_block_num")
    Dim oJBlock As Linq.JObject

    For lBlockID As Long = lLastBlockID - 50 To lLastBlockID
        oJBlock = oGolos.get_block(lBlockID)
     ... Process block ...
    Next
End Using

For security reasons, CGolosWallet still requires a local node.

Golos.NET is open source

Full source code can be found on github here and is available for VB.NET and C#.NET.

Support

I will maintain and improve the library as I am using it for several projects. If you have any comment, request or want to add your own touch to the project, feel free to contact me on golos.net channel on chat.golos.io.


Hopefully this will allow developers to build amazing tools and help the Golos community to grow.


Голосуйте за меня в качестве делегата

Вы также можете проголосовать прямо со Голос здесь. Для этого внизу страницы нужно проделать следующее


Если Вам понравился этот пост,
не забудьте проголосовать или подписаться на меня или поделиться


5
36.040 GOLOS
Комментарии (3)
Сортировать по:
Сначала старые