Skip to content

Latest commit

 

History

History
89 lines (66 loc) · 2.72 KB

README.md

File metadata and controls

89 lines (66 loc) · 2.72 KB

SiaSkynet C# SDK

This library enables all C# developers in the world to use SkyDB.

One of the most exciting features of this SDK is the full compatibility with Blazor WebAssembly. Blazor allows you to create C# apps and run them entirely in the browser using WebAssembly. The app can then be uploaded to Skynet for hosting.

Combining the large C# ecosystem with the power of SkyDB and the speed of WebAssembly makes this solution ready for a decentralized future!

Try out the Sample App or watch the Video demo

Also see SkyDocs


Sia Skynet client

  • Upload and download files from Sia Skynet.
  • Interact with the registry
  • Use SkyDB

How to use

See included test project and Blazor sample app.

Install: SiaSkynet on NuGet

Initialize the client

var _client = new SiaSkynetClient();

Upload a file

string fileName = "test.txt";
using (var fileStream = File.OpenRead(fileName))
{
    var response = await _client.UploadFileAsync(fileName, fileStream);
    var skylink = response.Skylink;
}

Download a file

string skylink = "AAAAQZg5XQJimI9FGR73pOiC2PnflFRh03Z4azabKz6bVw";
using (var response = await _client.DownloadFileAsStreamAsync(skylink))
{
    using (StreamReader sr = new StreamReader(response))
    {
        string text = await sr.ReadToEndAsync();
    }
}

Use these methods if you also want the original filename and content type.

_client.DownloadFileAsStringAsync(skylink);
_client.DownloadFileAsByteArrayAsync(skylink);

SkyDB

Support for SkyDB https://siasky.net/docs/#skydb

Set and get values on SkyDB:

var key = await SiaSkynetClient.GenerateKeys("my private key seed");

var success = await _client.SkyDbSetAsString(key.privateKey, key.publicKey, "datakey", "data");

string result = await _client.SkyDbGetAsString(key.publicKey, "datakey");

Assert.AreEqual("data", result);

Registry

SkyDB uses the Skynet Registry, it's also possible to interact with the registry using API's:

  • siaSkynetClient.GetRegistry
  • siaSkynetClient.SetRegistry
  • siaSkynetClient.UpdateRegistry which performs a get and a set with a new revision number

Reference

Apps that use this library:

Are you using SiaSkynet? Get your app listed here! Edit this page and send a pull request.