项目作者: michielpost

项目描述 :
Sia Skynet client
高级语言: C#
项目地址: git://github.com/michielpost/SiaSkynet.git
创建时间: 2020-05-25T07:37:29Z
项目社区:https://github.com/michielpost/SiaSkynet

开源协议:MIT License

下载


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

  1. var _client = new SiaSkynetClient();

Upload a file

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

Download a file

  1. string skylink = "AAAAQZg5XQJimI9FGR73pOiC2PnflFRh03Z4azabKz6bVw";
  2. using (var response = await _client.DownloadFileAsStreamAsync(skylink))
  3. {
  4. using (StreamReader sr = new StreamReader(response))
  5. {
  6. string text = await sr.ReadToEndAsync();
  7. }
  8. }

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

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

SkyDB

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

Set and get values on SkyDB:

  1. var key = await SiaSkynetClient.GenerateKeys("my private key seed");
  2. var success = await _client.SkyDbSetAsString(key.privateKey, key.publicKey, "datakey", "data");
  3. string result = await _client.SkyDbGetAsString(key.publicKey, "datakey");
  4. 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.