CHIA-RPC 1.8.2.13

There is a newer version of this package available.
See the version list below for details.
dotnet add package CHIA-RPC --version 1.8.2.13                
NuGet\Install-Package CHIA-RPC -Version 1.8.2.13                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CHIA-RPC" Version="1.8.2.13" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CHIA-RPC --version 1.8.2.13                
#r "nuget: CHIA-RPC, 1.8.2.13"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CHIA-RPC as a Cake Addin
#addin nuget:?package=CHIA-RPC&version=1.8.2.13

// Install CHIA-RPC as a Cake Tool
#tool nuget:?package=CHIA-RPC&version=1.8.2.13                

Welcome to the CHIA-RPC Nuget package!

This package is a wrapper for RPC-JSON files used to communicate with the Chia client through the HTTP-API, WebSocket API, or CLI.
The wrapper allows you to easily create the appropriate RPC object for all wallet endpoint calls, and deserialize the response JSON and accessing its objets.

CHIA-RPC ONLY contains the rpc wrappers (.net objects for RPC, Response and Chia Objects) In ;rder to cummiunicate with the chia client, you need to either implement your own client solution or use the Chia-Client-API package which implements all rpc endpoints and supports remote management of the chia client.

Usage

General functions

All classes support the following base functions:

  • SaveToFile(string path): saves the rpc as a json-formatted file to the specified path on disk.
  • LoadFromFile(string path): loads an rpc file from the specified path from disk.
  • ToString(): returns a json-formatted string representation of the class.
  • LoadObjectFromString(string json): converts a json string (eg. response) into a given object.

Types

There are 3 types in this library:

  • EndpointName_RPC these classes represent the request content which is issued against the chia client.
  • EndpointName_Response these classes represent the chia clients response and are beeing used to deserialize the server response into workable c# objects
  • ObjectName these classes represent objects in the chia space such as a CoinRecord, a Transaction and so on

RPC Creation

Most endpoints are implemented with a constructor:

// Create a new instance of the SendXCH_RPC class
var rpc = new SendXCH_RPC(1234, "chia1q2jzm7eg5t2k8vnq3tkkf5l7zj9mfx9v7p9t5", 1000, 500, new string[] { "Transaction from Example program" })

If this is not the case or for whatever other reason, You can also creath them like so:

// Create a new instance of the SendXCH_RPC class
var rpc = new SendXCH_RPC
{
    wallet_id = 1234,
    address = "chia1q2jzm7eg5t2k8vnq3tkkf5l7zj9mfx9v7p9t5",
    amount = 10000,
    fee = 500,
    memos = new string[] { "Transaction from Example program" }
};

Some endpoints already implement Constructors which make things a litte easier:

GetNextAddress_RPC rpc = new GetNextAddress_RPC(1, false);

Some endpoins already have implicit conversions which make working a lot easier. The support is quite sparse still:

WalletID_Response walletID = WalletID_Response.LoadResponseFromString(serverResponse);
GetNextAddress_RPC rpc = new GetNextAddress_RPC(walletID);

Serialisation

in order to work with the rpcs, you want to serialize/deserialize them to and from json.

Serialisation

All classes have a .ToString() method to convert a class to json content:

WalletID_RPC rpc = new WalletID_RPC(1);
string json = rpc.Tostring();
Deserialisation

Deserialisation is implemented as static method and can be used to convert the server response:

GetNextAddress_Response nextAddress = GetNextAddress_Response.LoadResponseFromString(serverResponse);

IO

Often it can be helpful to load and store objects such as an initiated transaction to disk for later reuse:

Saving object to disk

All objects and classes implement a SaveToFile method. The method automatically appends a filename .rpc .response or .object in respect of the basetype

TransactionID_Response pendingTransaction = new TransactionID_Response();
pendingTransaction.SaveResponseToFile("C:\\temp\\pendingTransactions\\mytransaction-001");
Loading object from disk

Simmilar to the Deserialisation, loading from disk is implemented as a static method:

TransactionID_Response pendingTransaction = TransactionID_Response.LoadResponseFromFile("C:\\temp\\pendingTransactions\\mytransaction-001");

Remarks

The structure of the chia API can be confusing and many rpcs (eg WalletID_RPC) are used for multiple endpoints so it is strongly recommended to use the Chia-Client-API to see how the interaction with the RPC requests is.

Per default, the chia client will only listen to rpc requests from the local machine.
If you have remote machines to manage, eg a full node or farmers, you need to enable public port listening.
For that, edit the chia configuration (default at ~/.chia/mainnet/config/config.yaml).
Look for a line starting with self-hostname like so: self_hostname: &self_hostname "localhost"
change it to: self_hostname: 0.0.0.0 to listen on all interfaces or to the local interface ip to listen on a specific interface.

For a full documentation besides xml markup, please refer to the official chia documentation: https://docs.chia.net/rpc

Thank you for using CHIA-RPC!

Dependencies

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CHIA-RPC:

Package Downloads
Chia-Client-API

CHIA-RPC is a C# Nuget library that allows developers to easily communicate with the Chia client. It provides a wrapper for making requests, sending transactions, and minting, making it a versatile tool for interacting with the Chia blockchain. With CHIA-RPC, you can easily integrate Chia functionality into your C# projects.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.0.17 186 3/13/2024
2.2.0.10 126 3/5/2024
2.2.0 137 3/1/2024
2.1.3 217 12/21/2023
2.1.1.8 169 12/8/2023
2.1.1.7 173 11/26/2023
2.1.1.6 168 11/15/2023
2.1.1.5 142 11/15/2023
2.1.1.4 148 11/9/2023
2.1.1.2 168 10/19/2023
2.1.1 176 10/13/2023
2.0.1 164 10/5/2023
2.0.0.1 186 8/31/2023
2.0.0 190 8/28/2023
1.8.2.13 224 8/22/2023
1.8.2.5 221 8/10/2023
1.8.2.4 192 8/9/2023
1.8.2.3 205 8/9/2023
1.8.2.2 189 8/9/2023
1.8.2.1 195 8/9/2023
1.8.2 193 7/26/2023
1.8.1.16 197 6/26/2023
1.8.1.15 209 6/23/2023
1.8.1.14 214 6/22/2023
1.8.1.13 189 6/22/2023
1.8.1.12 196 6/22/2023
1.8.1.11 201 6/22/2023
1.8.1.10 192 6/22/2023
1.8.1.9 210 6/21/2023
1.8.1.8 213 6/14/2023
1.8.1.7 204 6/14/2023
1.8.1.6 219 6/12/2023
1.8.1.5 228 6/9/2023
1.8.1.4 206 6/9/2023
1.8.1.3 210 6/9/2023
1.8.1.2 200 6/7/2023
1.8.1.1 202 6/7/2023
1.8.1 197 6/2/2023
1.8.0 209 5/11/2023
1.7.1 247 4/21/2023
1.6.2.14 367 2/8/2023
1.6.2.13 336 2/8/2023
1.6.2.12 360 2/5/2023
1.6.2.11 278 2/5/2023
1.6.2.10 288 2/5/2023
1.6.2.9 417 1/31/2023
1.6.2.8 388 1/28/2023
1.6.2.6 467 1/25/2023
1.6.2.5 355 1/24/2023
1.6.2.4 339 1/17/2023
1.6.2.3 359 1/16/2023
1.6.2.2 354 1/15/2023
1.6.2.1 362 1/13/2023
1.6.2 370 1/12/2023
1.6.1.5 388 1/11/2023
1.6.1.3 420 1/10/2023
1.6.1.2 313 1/10/2023
1.6.1.1 358 12/29/2022
1.6.1 324 12/29/2022

1.8.2.13
- restore of chia-rpc project file which got corrupted for unknown reasons
- updated the code to fetch the primary coin from a transaction
- added amount in cat to transaction
- made coin documentation clearer
- Marked GetCoinID() as deprecated (use CoinName property instead)
- implemented lazy loading and caching for CoinName
- added amount in cat property to coin
- reworked getPrimaryCoin
- added custom transaction type
- added a transaction invalidity check
- added implicit conversion from WalletID_RPC to ulong (Wallet ID)

1.8.2.5
This is a Major overhaul of the Package.
It implements nullable types for all endpoints. It is likely to require code changes or otherwise at least produces plentiful null value compiler warnings.

1.8.2.4
- hotfix for peer (has no attribute names)
- added unit test

1.8.2.3
- timestamps can now be read as DateTime
- improved resiliense and error handling in case of serialisation failures

1.8.2.2
- Included Peer object
- updated transaction documentationfor `sent_to` and `sent`
- changed `sent_to`  from `dynamic?` to `Peer[]?`
related documentation: https://docs.chia.net/walletconnect-commands?_highlight=sent#transactionrecord

1.8.2.1
This is a minor update that introduces changes to Transaction, Transaction Dict Memos, Transaction no memos, and GetTransaction:
- Added the TransactionType enum, making it easier to identify the type of a transaction.
- Added an unknown wallet type, "Ratelimited Wallet," to the WalletType enum.

1.8.2
This release presents a major overhaul of the package, implementing nullable types for all endpoints. It's likely that this will necessitate code changes, or at the very least, produce numerous null value compiler warnings.

Enhanced features:
- Improved Null Parameter Handling: The RPC interface now accurately manages null input parameters. This ensures the application won't crash or exhibit unintended behavior when a null value is passed.
- RPC Parameter Nullability: All RPC parameter objects are now nullable, enhancing request integrity and the stability of our API communication.
- Null Checks in RPC Methods: Functions, such as BatchUpdate_Async, now ascertain if their essential parameters are null prior to execution. This preemptive action helps detect issues early, returning a helpful error message instead of triggering unexpected runtime exceptions.
- Null Reference Exception Fixes: Addressed potential NullReferenceExceptions.
- Expanded XML Comments: We have significantly added to or expanded the XML comments across numerous classes and methods. These annotations act as in-code documentation, offering valuable context and guidance for developers.
- Compiler Warnings: Resolved all compiler warnings within the package.

Please refer to the documentation and the updated code comments for a deeper understanding of these updates. As always, we welcome any issue reports or feedback on these modifications.