-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
This is a quick start sample for new and existing .Net developers with minimal dependencies.
The ProximaX.Sirius.Chain.SDK is developed target .Net Standard 2.0, hence it is compatible with most operating systems (Windows, MacOS, Linux, and Android).
The ProximaX.Sirius.Chain.SDK works with .Net Core 2.0 or .Net Framework 4.6.1 and above. You will need the .Net SDK installed in your development environment.
Download the .Net SDK here
Note: It is recommended to use .Net Core 2.0 and above to develop your application either in Mac, Windows or Linux environment.
Create your application using either the .Net CLI or the Visual Studio tools
dotnet new console -o ProximaXSiriusExamples
cd ProximaXSiriusExamples
In .Net Core
dotnet add package csharp-xpx-chain-sdk
dotnet restore
If you are using legacy .Net Framework 4.6.1 and above
Install-Package csharp-xpx-chain-sdk
Visual Studio Code and Visual Studio are very good IDE editors for .Net development.
Open the Program.cs file in your favourite editor.
- First, you need to add the required namespaces ProximaX.Sirius.Chain.SDK for your application.
using Proximax.Sirius.Chain.Sdk;
using Proximax.Sirius.Chain.Sdk.Client;
-
Next, create an instance of SiriusClient, with the host URL for the ProximaX Sirius platform networks.
See the list of public networks here
var siriusClient = new SiriusClient("https://bctestnet1.xpxsirius.io");
- Use the SiriusClient instance to verify the live network and get the current network type information.
var networkType = await siriusClient.NetworkHttp.GetNetworkType();
Console.WriteLine($"Current Network Type {networkType}");
- The Proximax.Sirius.SDK library leverage the Reactive Extensions(Rx) library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. An alternative to use async/await like above, you can get the network type information by subscribing to the event stream.
siriusClient.NetworkHttp.GetNetworkType().Subscribe(
// getting response info
networkInfo =>
Console.WriteLine($"Current Network Type {networkType}"),
// if any error occurred
error =>
Console.WriteLine($"Unexpected error occurred {error}")
)
- Full sample code for Program.cs below
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Proximax.Sirius.Chain.Sdk.Client;
namespace Proximax.Sirius.Sdk.NetCore.Examples
{
class Program
{
static void Main(string[] args)
{
GetNetworkTypeInfo().Wait();
}
private static async Task GetNetworkTypeInfo()
{
var siriusClient = new SiriusClient("https://bctestnet1.xpxsirius.io");
var networkType = await siriusClient.NetworkHttp.GetNetworkType();
Console.WriteLine($"Current Network Type {networkType}");
}
}
}