Ajuna SDK is a .NET toolchain featuring .NET framework extensions and code generation utilities to build substrate storage services and clients quickly. This toolchain ideally extends Ajuna.NetApi library, which provides raw access to substrate nodes.
This toolchain is under development, and things may change quickly.
Below is a high-level technical overview of the libraries and tools available in Ajuna.SDK.
Assuming your substrate node is running locally, you're ready to build your services and clients using the Ajuna SDK toolchain.
Install our .NET template with the following command:
dotnet new --install Ajuna.DotNet.Template
which makes dotnet new ajuna
available.
Using a terminal of your choice, create a new directory for your project and execute the following command in that directory:
dotnet new sln
dotnet new ajuna \
--sdk_version 0.2.3 \
--rest_service AjunaExample.RestService \
--net_api AjunaExample.NetApiExt \
--rest_client AjunaExample.RestClient \
--metadata_websocket ws://127.0.0.1:9944 \
--generate_openapi_documentation true \
--force \
--allow-scripts yes
which generates a new solution and a couple of .NET projects in your project directory. (A description for all command parameters can be found here)
.
├─── .ajuna
├─── .config
├─── AjunaExample.NetApiExt
├─── AjunaExample.RestClient
├─── AjunaExample.RestClient.Mockup
├─── AjunaExample.RestClient.Test
├─── AjunaExample.RestService
Before elaborating on each of the generated projects, let’s first talk about Ajuna.NetApi which is the basis that these projects are built upon.
Ajuna.NetApi
is the basic framework for accessing and handling JSON-RPC connections and handling all standard RPC calls exposed by the rpc.methods()
of every substrate node. It additionally implements Rust primitives and Generics as a C# representation like U8, BaseVec (Vec<>), or EnumExt (Rust-specific Enums).
Since Ajuna.NetApi
has no other types than the ones previously described, accessing a node’s storage or sending extrinsic would involve manually creating the necessary types. This is where the generated Ajuna.NetApiExt
comes into play since it extends Ajuna.NetApi
by exposing all the node-specific types, storage access, extrinsic calls and more.
This service:
- Connects to a node and subscribes to the global storage changes, which are then maintained in memory.
- Offers a REST service (poll) which exposes all the storage information as REST.
- Offers a subscription service (pub/sub) providing changes over a WebSocket.
The benefit of this approach is that this artifact is much more lightweight than the node itself and can therefore be scaled according to the needs of the consumers without putting any load on an RPC node except for one connection (per RestService instance) for the global storage subscription.
This RestClient can be used in a C#, Unity, or any other application allowing it to access the information provided by the previously described RestService. Using the RestClient one could subscribe to the node storage changes using the WebSocket or access the storage directly through exposed REST service.
As you can see, we could in principle launch any service or create any application on top of Substrate without any further knowledge except from the library usage.
The generated projects contain everything you need in order to get started making excellent substrate services and clients in C# and the .NET framework.
You can also watch our short step-by-step tutorial that guides you through the entire process.
- Contributing
- Development
- Examples
dotnet ajuna
toolchain with Ajuna.DotNetdotnet new ajuna
template with Ajuna.DotNet.Template
The project behind Ajuna.SDK is Ajuna Network and the flagship game DOTMog, backed by the Swiss company BloGa Tech AG.