CHIA-RPC
2.2.0.17
dotnet add package CHIA-RPC --version 2.2.0.17
NuGet\Install-Package CHIA-RPC -Version 2.2.0.17
<PackageReference Include="CHIA-RPC" Version="2.2.0.17" />
paket add CHIA-RPC --version 2.2.0.17
#r "nuget: CHIA-RPC, 2.2.0.17"
// Install CHIA-RPC as a Cake Addin #addin nuget:?package=CHIA-RPC&version=2.2.0.17 // Install CHIA-RPC as a Cake Tool #tool nuget:?package=CHIA-RPC&version=2.2.0.17
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 theChia-Client-API
package which implements all rpc endpoints and supports remote management of the chia client.
Useful links
- nuget package: https://www.nuget.org/packages/CHIA-RPC
- github repo to submit issues/requests: https://github.com/KryptomineCH/CHIA-RPC
- official chia rpc documentation: https://docs.chia.net/rpc/
- chia-client-api for communication with the chia client: https://www.nuget.org/packages/Chia-Client-API/
Usage
Settings
Settings are beeing stored in CHIA_RPC.General_NS.Settings
ReportErrors
(default: false) opt in, to send error reports anonymously to kryptomine.ch to improve the library
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.
Helper Variables
You can find some helper variables in CHIA_RPC.General_NS.GlobalVar
:
OneChiaInMojos
(1000000000000)OneCatInMojos
(1000)PackageVersion
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# objectsObjectName
these classes represent objects in the chia space such as aCoinRecord
, aTransaction
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 create 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 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 theChia-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 | Versions 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 was computed. 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 is compatible. 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. |
-
net6.0
- Chia-Metadata (>= 1.8.2)
- NFT.Storage.Net (>= 1.0.1.2)
- SSH.NET (>= 2023.0.0)
-
net8.0
- Chia-Metadata (>= 1.8.2)
- NFT.Storage.Net (>= 1.0.1.2)
- SSH.NET (>= 2023.0.0)
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 | 188 | 3/13/2024 |
2.2.0.10 | 128 | 3/5/2024 |
2.2.0 | 145 | 3/1/2024 |
2.1.3 | 219 | 12/21/2023 |
2.1.1.8 | 171 | 12/8/2023 |
2.1.1.7 | 175 | 11/26/2023 |
2.1.1.6 | 170 | 11/15/2023 |
2.1.1.5 | 144 | 11/15/2023 |
2.1.1.4 | 150 | 11/9/2023 |
2.1.1.2 | 170 | 10/19/2023 |
2.1.1 | 178 | 10/13/2023 |
2.0.1 | 166 | 10/5/2023 |
2.0.0.1 | 188 | 8/31/2023 |
2.0.0 | 192 | 8/28/2023 |
1.8.2.13 | 228 | 8/22/2023 |
1.8.2.5 | 223 | 8/10/2023 |
1.8.2.4 | 194 | 8/9/2023 |
1.8.2.3 | 207 | 8/9/2023 |
1.8.2.2 | 193 | 8/9/2023 |
1.8.2.1 | 197 | 8/9/2023 |
1.8.2 | 194 | 7/26/2023 |
1.8.1.16 | 198 | 6/26/2023 |
1.8.1.15 | 213 | 6/23/2023 |
1.8.1.14 | 216 | 6/22/2023 |
1.8.1.13 | 191 | 6/22/2023 |
1.8.1.12 | 200 | 6/22/2023 |
1.8.1.11 | 203 | 6/22/2023 |
1.8.1.10 | 194 | 6/22/2023 |
1.8.1.9 | 214 | 6/21/2023 |
1.8.1.8 | 215 | 6/14/2023 |
1.8.1.7 | 205 | 6/14/2023 |
1.8.1.6 | 221 | 6/12/2023 |
1.8.1.5 | 229 | 6/9/2023 |
1.8.1.4 | 208 | 6/9/2023 |
1.8.1.3 | 212 | 6/9/2023 |
1.8.1.2 | 201 | 6/7/2023 |
1.8.1.1 | 204 | 6/7/2023 |
1.8.1 | 199 | 6/2/2023 |
1.8.0 | 213 | 5/11/2023 |
1.7.1 | 249 | 4/21/2023 |
1.6.2.14 | 369 | 2/8/2023 |
1.6.2.13 | 340 | 2/8/2023 |
1.6.2.12 | 364 | 2/5/2023 |
1.6.2.11 | 281 | 2/5/2023 |
1.6.2.10 | 290 | 2/5/2023 |
1.6.2.9 | 419 | 1/31/2023 |
1.6.2.8 | 390 | 1/28/2023 |
1.6.2.6 | 469 | 1/25/2023 |
1.6.2.5 | 356 | 1/24/2023 |
1.6.2.4 | 340 | 1/17/2023 |
1.6.2.3 | 361 | 1/16/2023 |
1.6.2.2 | 356 | 1/15/2023 |
1.6.2.1 | 364 | 1/13/2023 |
1.6.2 | 372 | 1/12/2023 |
1.6.1.5 | 390 | 1/11/2023 |
1.6.1.3 | 421 | 1/10/2023 |
1.6.1.2 | 315 | 1/10/2023 |
1.6.1.1 | 360 | 12/29/2022 |
1.6.1 | 326 | 12/29/2022 |
2.2.0.17
- hotfix for GetOfferSummary_Response (please report if there is an issue. Its not documented on chia docs)
2.2.0.10
- Fix Mempool related objects for get_all_mempool_items
- Add Custom Property FeePerCost to Mempool Item
- Update Block RPC
- Add implicit conversions from block record to header hash
- Fix response raw content
- Add fee_xch to Mempool item
- User can now decide if raw response should be included or not
- implement get_wallet_addresses
2.2.0
- Implement Datalayer get_proof
- implement Datalayer verify_proof
- implement get_aggsig_additional_data
- add implicit conversion to GetSpendableCoins_RPC
- added GetSortedCoins to GetSpendableCoins_Response
- added GetSortedCoins to GetSpendableCoins_Response
- added Bech32 helperFunctions
- Reverse engineered, fixed and tested send_transaction_multi
- add support for .net 8.0
- removed parameter from nft_nft_get_nfts according to documentation update
2.1.3
- removed ammount_correct_custom as it was a workaround for a bug in outgoing trades in previous chia versions
- Compatible with chia 2.1.2
2.1.1.8
- update offer sort key
- add Websocket implementation (only compatible with linux < chia 2.1.2)
requires tls 1.2 allowance in chia config for windows on chia >= 2.1.2
- fixed a bug where the client could not load the endpoint
2.1.1.7
- added workaround for amount in cat
- added information to OfferSummary if the offer will generate a separate fee transaction for the person accepting the offer
- added information to TradeRecord if this offer generates a separate fee transaction for you
- traderecord status is now the apropriate enum TradeStatus
- added implicit conversion from TransactionDict to WalletID_RPC
- added functionality to check if the file exists on disk due to extension
- added efficient hash comparing function to CHIA_RPC.HelperFunctions_NS.HashCompare
- added utility comparing operations to coin. ==, != and .Equals()
- GetCoinID() is now deprecated. Please use the property CoinName
- added comparison function for two coin arrays
- added transaction comparison
- added implicit conversion from ulong to fingerprint_rpc
- added implicit operator for WalletID_RPC (ulong)
- added implicit operator for GetTransactions_RPC (walletID_RPC & ulong)
- improved deserializer error handling. They will no longer return a null value. Please check if bool success and string error
- Fixed Paths for Cross Plattform compatibility
2.1.1.6
- improved internal debug capabiolities
- worked on get primary coins
(!) added a critical workaround for chia <= 2.1.1 reporting incorrect amount in OUTGOING_TRADE transactions
use amount_correct_custom for now
see https://github.com/Chia-Network/chia-blockchain/issues/16842 for more details
2.1.1.5
- Updated GetAllOffers_RPC Documentation
- Updated get_all_offers sort_key type (string)
- Updated TradeRecord documentation with findings from offers
- Trade recod accepted_at_time can now be accessed through DateTime with accepted_at_time_dateTime
- NftCoinIdAndWalletId is noww a serializable object
- Format fix GetCoinRecords_Response documentation
- added opt in error reporting (must set CHIA_RPC.General_NS.Settings.ReportErrors = true )
- updated readme
- added offer summary and Asset info to offers (was dynamic object before)
2.1.1.4
- Updated Transactions documentation with its caviats
2.1.1.3
- Improved Documentation for GetTransactions_RPC
- Added jsonignore for offer_in_xch (because its a custom property)
- Updated GetTransactions Documentation
- Updated Transaction Documentation
2.1.1.2
- added opt-in error transmit feature improvement program.
- Transmitts error responses of the server in rsa4096 encrypted manner if opted in. Keys are not included. More details in the parameter documentation where creating the api instance.
- typo corrections in WalletApi_wallet and WalletApi_WalletNode
2.1.1.1
- Fixed an error where AwaitOfferToExecuteOrCancel gets stuck when called with an invalid offer
- Implemented Globalvar - packageVersion
2.1.1
- Improved nft documentation
- Added functionality to await until an offer is executed or cancalled/invaild
- Added implicit conversion for takeOffer RPC
- Update AddOfferPosition (now supports cat and updated documentation)
- added daemon endpoints
- added implicit conversions for fingerprint rpc
- implemented daemon rpc endpoints
- Implemented Verifiable Credentials endpoints
- update NftMintBulk according to documentation
- add clear_pending_roots endpoint according to documentation
- implemented time-limited offers