Skip to content

Latest commit

 

History

History
49 lines (29 loc) · 7.67 KB

08-30-substrate-toolchain-for-net.md

File metadata and controls

49 lines (29 loc) · 7.67 KB

Introduction to Substrate NET Toolchain/SDK and Unity integration

The Substrate Toolchain for NET generates a full-fledged ready-to-hack Substrate SDK from any Substrate node compatible with metadata V14. This toolchain is usable for any NET Applications and/or Unity.

The goal of this seminar is to show developers how to use a NET SDK (NET Standard 2.0 for maximum compatibility with Unity) to build applications from the metadata of any Substrate node.

📆 Join the Crowdcast: https://www.crowdcast.io/e/substrate-seminar-2/23

This seminar will be useful for developers who want to learn how to use the toolchain, specifically:

  • C# developers
  • Game developers trying to use leading game engines Unity or Unreal (UnrealCLR) with Substrate

Outline

  • Usage of the SDK
  • Showcase exisiting projects
  • Build a working Unity app
  • Get in involved

Learn more

Ajuna.NetApi, is the basic framework for accessing and handling JSON-RPC connections and handling the generic RPC calls that every substrate node offer and are exposed by the rpc.methods(). It additionally implements rust primitives and generics as a C# representation like U8, BaseVec (Vec<>), or EnumExt (Rust-specific Enums). The Ajuna.NetApi has no other types than the ones previously described, so accessing the node storage or sending extrinsic would involve manually creating the necessary types.

Ajuna.NetApiExt is the extension of the NetApi, with a generated client extension, adding all the node-specific types, storage access, extrinsic calls and more to the client. As an example, here is the FrameSystem. With the API and the Extensions, all possible interactions with a node and the specific network are given. However, if your application is targeted to be used by many consumers and needs to be on high availability to provide storage access or storage subscription, then accessing or subscribing straight to a node might be an issue in terms of scalability, but also in terms of efficiency.

Ajuna.RestService, this service, in its core, just connects to a node and subscribes to the global storage changes, which are then maintained in memory. It holds all stored items exposed from a node and maintains them, and builds a swagger endpoint. On top, there is a REST service (poll) exposing all the storage information as REST, and additionally, there is a subscription service (pub/sub) providing changes over a WebSocket. This artifact is much more lightweight than the node and can be scaled according to the needs of the consumers without putting any load on an RPC node except for one connection for the global storage subscription.

image

Ajuna.RestClient is the artifact used in the client application C#, Unity, or whatever is using the client to access the information. It is the counterpart for the previously described service, allowing you to subscribe to storage through the WebSocket or access storage through REST and providing it in an intuitive C# manner, where you can build events on storage changes and access REST by using the prepared node specific library. As an example, here is the pre-generated access for an account subscription (subscribe, await) or getting the account through rest (polling). This allows once you build your node specific SDK. You launched your Service to create Applications on top of the substrate without any further knowledge except the library usage.

image

Resources

Here are some projects developed by Ajuna:

Project Description NuGet
Ajuna.NetApi Ajuna .NET API Full-featured substrate node API. Nuget
Ajuna.ServiceLayer Implements the fundamental layer to access substrate node storage changes with a convenient API. Nuget
Ajuna.ServiceLayer.Model Implements standard classes to easily share types between services and clients. Nuget
Ajuna.AspNetCore Implements extensions to the service layer that allow for quickly building a RESTful service to access your substrate node storage. Nuget
Ajuna.DotNet, Ajuna.DotNet.Template .NET developer toolchain to scaffold actual projects such as a RESTful service including all the storage classes, types, and consumer clients. The projects generated with the generator toolchain are intended to be used for scaffolding and starting a substrate node service quickly. Nuget Nuget