Skip to content

Repository files navigation

SubstrateNET

Generated Substrate NET SDK

This is a NET playground repo for the published monthly substrate tags. To build towards a specific node, please follow the documentation in the Ajuna.SDK repo.

image

How to use

Run local substrate node

Currently you should find for the most actual monthly build a pre-generated tag in this repo, so make sure you chose a supported monthly substrate tag (ex. monthly-2022-11)

git clone -b monthly-2022-11 --single-branch https://github.com/paritytech/substrate.git
cargo build -p node-cli --release
./target/release/substrate --dev

Load SubstrateNET

Use the same tag for the SubstrateNET.

git clone -b monthly-2022-11 --single-branch https://github.com/ajuna-network/SubstrateNET.git

Launch Solution

Load solution SubstrateNET.sln

Launch Service

Execute SubstrateNET.RestService

  • might ask you to accept certificates for ssl

Access Endpoints & Swagger

Simple Program

A simple Program.cs to start hacking!

start hacking with the SDK

usingSystem;usingSystem.Threading;usingSystem.Threading.Tasks;usingSerilog;namespaceAjuna.NetApi.RunConsole{internalclassProgram{privatestaticasyncTaskMain(string[]args){varconfig=newLoggerConfiguration();Log.Logger=config.MinimumLevel.Debug().WriteTo.Console().CreateLogger();// CancellationToken that is canceled when the user hits Ctrl+C.varcts=newCancellationTokenSource();Console.CancelKeyPress+=(s,e)=>{Console.WriteLine("Canceling...");cts.Cancel();e.Cancel=true;};try{Console.WriteLine("Press Ctrl+C to end.");awaitMainAsync(cts.Token);}catch(OperationCanceledException){// This is the normal way we close.}}privatestaticasyncTaskMainAsync(CancellationTokentoken){varsubstrateClient=newSubstrateClient(newUri("ws://127.0.0.1:9944"));awaitsubstrateClient.ConnectAsync(true,CancellationToken.None);Log.Information("substrateClient.IsConnected: {IsConnected}",substrateClient.IsConnected);varblockData=awaitsubstrateClient.Chain.GetBlockAsync();Log.Information("blockData: {blockData}",blockData);}}}

About

Generated Substrate NET SDK

Resources

Stars

3 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages