Giter Club home page Giter Club logo

chia-dotnet's Introduction

chia-dotnet

A .net client library for chiaโ„ข RPC interfaces that runs on linux and windows.

build CodeQL NuGet

Getting Started

Documentation

https://dkackman.github.io/chia-dotnet/

Features

  • Coverage of all of chia's rpc endpoints
    • Daemon, Full Node, Farmer, Harvester, Wallet, Plotter, Crawler, DataLayer
  • Coverage of all of the methods at each endpoint
    • as of 2.1.0
  • Static types for chia input and outputs
  • Supports connecting via the daemon on wss or directly to each service with https
    • both https and wss use tha same interfaces so switching is seamless

Examples

Test carefully and in one of the testnets!

Example app

Try the example code or take a look at rchia remote chia management CLI.

Connect to the Node and find out about the blockchain

var endpoint = Config.Open().GetEndpoint("daemon");
using var rpcClient = new WebSocketRpcClient(endpoint);
await rpcClient.Connect();

var daemon = new DaemonProxy(rpcClient, "unit_tests");
await daemon.RegisterService();

var fullNode = new FullNodeProxy(rpcClient, "unit_tests");
var state = await fullNode.GetBlockchainState();
Console.Writeline($"This node is synced: {state.Sync.Synced}")

Send me some chia

var endpoint = Config.Open().GetEndpoint("wallet");
using var rpcClient = new HttpRpcClient(endpoint);

var wallet = new WalletProxy(rpcClient, "unit_tests");
await wallet.WaitForSync();

// walletId of 1 is the main XCH wallet
var standardWallet = new Wallet(1, wallet);

// this is my receive address. feel free to run this code on mainnet as often as you like :-)
var transaction = await standardWallet.SendTransaction("xch1ls2w9l2tksmp8u3a8xewhn86na3fjhxq79gnsccxr0v3rpa5ejcsuugha7", 1, 1);

Build

dotnet build ./src

Install from nuget.org

dotnet add package chia-dotnet

Tests

There are various unit and integration tests in the test project that have example usage. Tests attributes with [TestCategory("Integration")] will use the local install of chia and the mainnet configuration to resolve RPC endpoints.

Tests decorated with [TestCategory("CAUTION")] update the state of whatever they are interacting with. Run these tests with caution. If run against a production node on mainnet, they might change things, up to and including deleting keys or sending chia out of your wallet.

Some Notes About Types and Naming

In addition to static vs dynamic typing, C# and Python have very different conventions for naming and formatting. For the most part I've tried to make this library fit into dotnet conventions. Please open an issue if something doesn't feel dotnet-y.

  • Method and property names are ProperCased.
  • Parameter names are camelCased.
  • The chia RPC uses unsigned integers where dotnet might use signed. In cases where chia expects an unsigned number, it is unsigned on the dotnet side.
  • ulong is used for the python 64 bit unsigned int.
  • BigInteger is used for the python 128 bit unsigned int.
  • Where the RPC return a scalar value, the dotnet code will as well. If it is optional in python it will be Nullable<T> in dotnet
  • Where the RPC returns a list of named scalar values, they are returned as a Tuple with named fields.
  • Lists of things are returned as IEnumberable<T>.
  • Where the python code returns a differently shaped object based on its input or logic, the dotnet code is turned into multiple methods.
  • When the RPC returns a success flag equal to false, the dotnet code throws an exception.

chia and its logo are the registered trademark or trademark of Chia Network, Inc. in the United States and worldwide.

chia-dotnet's People

Contributors

dkackman avatar dependabot[bot] avatar wizicer avatar kevinonfrontend avatar joshpainter avatar

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.