![]() |
VOOZH | about |
dotnet add package XrplCSharp --version 1.0.0
NuGet\Install-Package XrplCSharp -Version 1.0.0
<PackageReference Include="XrplCSharp" Version="1.0.0" />
<PackageVersion Include="XrplCSharp" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="XrplCSharp" />Project file
paket add XrplCSharp --version 1.0.0
#r "nuget: XrplCSharp, 1.0.0"
#:package XrplCSharp@1.0.0
#addin nuget:?package=XrplCSharp&version=1.0.0Install as a Cake Addin
#tool nuget:?package=XrplCSharp&version=1.0.0Install as a Cake Tool
A pure C# implementation for interacting with the XRP Ledger, the XrplCSharp library simplifies the hardest parts of XRP Ledger interaction, like serialization and transaction signing, by providing native C# methods and models for XRP Ledger transactions and core server API (rippled) objects.
// create a network client
using System.Diagnostics;
using Xrpl.Client;
var client = new XrplClient("wss://s.altnet.rippletest.net:51233");
client.OnConnected += async () =>
{
Debug.WriteLine("CONNECTED");
};
await client.Connect();
// create a wallet on the testnet
XrplWallet testWallet = XrplWallet.Generate();
await WalletSugar.FundWallet(client, testWallet);
Debug.WriteLine(testWallet);
// public_key: ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56
// private_key: -HIDDEN -
// classic_address: rBtXmAdEYcno9LWRnAGfT9qBxCeDvuVRZo
// look up account info
//using System.Diagnostics;
//using Xrpl.Model.Account;
string account = "rBtXmAdEYcno9LWRnAGfT9qBxCeDvuVRZo";
AccountInfoRequest request = new AccountInfoRequest(account);
AccountInfo accountInfo = await client.AccountInfo(request);
Debug.WriteLine(accountInfo);
// {
// "Account": "rBtXmAdEYcno9LWRnAGfT9qBxCeDvuVRZo",
// "Balance": "1000000000",
// "Flags": 0,
// "LedgerEntryType": "AccountRoot",
// "OwnerCount": 0,
// "PreviousTxnID": "73CD4A37537A992270AAC8472F6681F44E400CBDE04EC8983C34B519F56AB107",
// "PreviousTxnLgrSeq": 16233962,
// "Sequence": 16233962,
// "index": "FD66EC588B52712DCE74831DCB08B24157DC3198C29A0116AA64D310A58512D7"
// }
The XrplCSharp library is available on DotNet. Install with dotnet:
dotnet add package XrplCSharp --version 1.0.0
The library supports Dotnet 6 and later.
Use XrplCSharp to build C# applications that leverage the XRP Ledger. The library helps with all aspects of interacting with the XRP Ledger, including:
XrplCSharp also provides:
xrpl.clients for more information.See the complete XrplCSharp reference documentation on Read the Docs.
The following sections describe some of the most commonly used modules in the XrplCSharp library and provide sample code.
Use the Xrpl.Client library to create a network client for connecting to the XRP Ledger.
using System.Diagnostics;
using Xrpl.Client;
var client = new XrplClient("wss://s.altnet.rippletest.net:51233");
client.OnConnected += async () =>
{
Debug.WriteLine("CONNECTED");
};
await client.Connect();
Xrpl.WalletUse the Xrpl.Wallet module to create a wallet from a given seed or or via a Testnet faucet.
To create a wallet from a seed (in this case, the value generated using Xrpl.Keypairs):
using System.Diagnostics;
using Xrpl.Wallet;
// ...
string seed = "s";
XrplWallet wallet = XrplWallet.FromSeed(seed);
Debug.WriteLine(wallet);
// pub_key: ED46949E414A3D6D758D347BAEC9340DC78F7397FEE893132AAF5D56E4D7DE77B0
// priv_key: -HIDDEN-
// classic_address: rG5ZvYsK5BPi9f1Nb8mhFGDTNMJhEhufn6
To create a wallet from a Testnet faucet:
using System.Diagnostics;
using Xrpl.Wallet;
XrplWallet testWallet = XrplWallet.Generate();
await WalletSugar.FundWallet(client, testWallet);
Debug.WriteLine(testWallet.ClassicAddress);
# Classic address: rEQB2hhp3rg7sHj6L8YyR4GG47Cb7pfcuw
Xrpl.KeypairsUse the Xrpl.Keypairs module to generate seeds and derive keypairs and addresses from those seed values.
Here's an example of how to generate a seed value and derive an XRP Ledger "classic" address from that seed.
using System.Diagnostics;
using Xrpl.Wallet;
// ...
XrplWallet wallet = XrplWallet.Generate();
string publicKey = wallet.PublicKey;
string privateKey = wallet.PrivateKey;
Debug.WriteLine("Here's the public key:");
Debug.WriteLine(publicKey);
Debug.WriteLine("Here's the private key:");
Debug.WriteLine(privateKey);
Debug.WriteLine("Store this in a secure place!");
// Here's the public key:
// ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56
// Here's the private key:
// EDE65EE7882847EF5345A43BFB8E6F5EEC60F45461696C384639B99B26AAA7A5CD
// Store this in a secure place!
Note: You can use Keypairs to sign transactions but XrplCSharp also provides explicit methods for safely signing and submitting transactions. See Transaction Signing and XRPL Transaction Methods for more information.
To securely submit transactions to the XRP Ledger, you need to first serialize data from JSON and other formats into the XRP Ledger's canonical format, then to authorize the transaction by digitally signing it with the account's private key. The XrplCSharp library provides several methods to simplify this process.
Use the xrpl.transaction module to sign and submit transactions. The module offers three ways to do this:
safe_sign_and_submit_transaction — Signs a transaction locally, then submits it to the XRP Ledger. This method does not implement reliable transaction submission best practices, so only use it for development or testing purposes.
safe_sign_transaction — Signs a transaction locally. This method does not submit the transaction to the XRP Ledger.
send_reliable_submission — An implementation of the reliable transaction submission guidelines, this method submits a signed transaction to the XRP Ledger and then verifies that it has been included in a validated ledger (or has failed to do so). Use this method to submit transactions for production purposes.
using System.Diagnostics;
using Xrpl.Models.Transactions;
using Xrpl.Models.Methods;
using Newtonsoft.Json;
// ...
string classicAddress = "rBtXmAdEYcno9LWRnAGfT9qBxCeDvuVRZo";
AccountInfoRequest request = new AccountInfoRequest(wallet.ClassicAddress);
AccountInfo accountInfo = await client.AccountInfo(request);
// prepare the transaction
// the amount is expressed in drops, not XRP
// see https://xrpl.org/basic-data-types.html#specifying-currency-amounts
IPayment tx = new Payment()
{
Account = wallet.ClassicAddress,
Destination = "rEqtEHKbinqm18wQSQGstmqg9SFpUELasT",
Amount = new Xrpl.Models.Common.Currency { ValueAsXrp = 1 },
Sequence = accountInfo.AccountData.Sequence
};
// submit the transaction
Dictionary<string, dynamic> txJson = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(tx.ToJson());
Submit response = await client.Submit(txJson, wallet);
Debug.WriteLine(response);
In most cases, you can specify the minimum transaction cost of "10" for the fee field unless you have a strong reason not to. But if you want to get the current load-balanced transaction cost from the network, you can use the Fees function:
using System.Diagnostics;
using Xrpl.Models.Transactions;
FeeRequest feeRequest = new FeeRequest();
Fee fee = await client.Fee(feeRequest);
Debug.WriteLine(fee);
# 10
If you want to contribute to this project, see .
We have a low-traffic mailing list for announcements of new XrplCSharp releases. (About 1 email per week)
If you're using the XRP Ledger in production, you should run a rippled server and subscribe to the ripple-server mailing list as well.
The XrplCSharp library is licensed under the ISC License. See for more information.
The credit of this repository goes to Chris Williams.
Thank you Chris.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on XrplCSharp:
| Package | Downloads |
|---|---|
|
OO.CryptoWallet
Crypto Currency and Wallet manager with utilities implementations for EasyDataCore infrastructure |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 778 | 4/30/2023 |