Getting started with Netezos.RPC

Baking Bad
Coinmonks
2 min readJul 10, 2019

--

Netezos is .NET Standard 2.0 libraries pack for working with Tezos. At the current stage, Netezos.Rpc is implemented. It provides access to the Tezos node via RPC API. Let’s a little dig into it and look at how it works.

Installation

Netezos.Rpc package is available on NuGet, a package manager for .NET developers. So you can install Netezos.Rpc via Nuget Package Manager GUI or by the following command:

PM> Install-Package Netezos.Rpc

Or just clone the project from GitHub repository.

Basic usage

There is the main class TezosRpc which you need to build the queries, supported by Tezos RPC API.

Let’s create an instance of TezosRpc class, build a simple GET query and execute it by calling GetAsync().

Note that the real HTTP request is sent only when you call GetAsync(). Until then, you work with just the query object, which can also be used to get subqueries.

Accessing blocks

You can access any block in two ways: by forward-indexing and by backward-indexing.

RpcList and RpcDictionary

The results of many RPC API methods can be interpreted as arrays or dictionaries that allow you to get many objects or only one by specifying a key or index.

Query parameters

If some RPC API method has query parameters, the corresponding query object will have the overridden GetAsync()methods.

Post methods

Using POST methods, you can pass the JSON string input.

The second option — pass an object to the PostAsync method.

And the third option — pass specific arguments to the PostAsync method.

Conclusion

In this article, we have described the most common use cases. Netezos.RPC is pretty flexible so can actually be used for much more cases related to working with Tezos blockchain via RPC API.

Netezos is an open-development project, so do not hesitate to participate by creating issues or making pull requests to our GitHub repo. Also, we are always glad to discuss any features in our Baking Bad telegram chat.

Cheers!

Originally published at https://baking-bad.org on July 10, 2019, where you can find full version of the article.

Get Best Software Deals Directly In Your Inbox

--

--

Baking Bad
Coinmonks

Baking-bad.org, Audit & Rating of Tezos bakers. Active Tezos tools contributor. Author of better-call.dev, Pytezos, Netezos, TzKT.io, atomex.me