GithubHelp home page GithubHelp logo

michielpost / siaskynet Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 5.0 339 KB

Sia Skynet client

License: MIT License

C# 82.01% HTML 12.84% CSS 5.15%
csharp sia siacoin skynet api-client sia-skynet web3 skydb

siaskynet's Introduction

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.

siaskynet's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

siaskynet's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.