RippleLibSharp Payment Example
Import the necessary libraries
using System.Threading;
using RippleLibSharp.Keys;
using RippleLibSharp.Network;
using RippleLibSharp.Result;
using RippleLibSharp.Transactions;
using RippleLibSharp.Transactions.TxTypes;
Connect to the xrp ledger
var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
ConnectionSettings connectInfo = new ConnectionSettings
{
ServerUrls = new string[] { "wss://s1.ripple.com:443", "wss://s2.ripple.com:443" },
LocalUrl = "localhost",
UserAgent = "optional spoof browser user agent",
Reconnect = true
};
NetworkInterface network = new NetworkInterface(connectInfo);
bool didConnect = network.Connect();
if (!didConnect) {
return;
}
Construct the payment transaction *Key code
var dest = new RippleAddress("rBuDDpdVBt57JbyfXbs8gjWvp4ScKssHzx");
var address =
new RippleAddress("rJ8UEAvqsMtQqaRv9VdasEyrf5DauwgZSg");
var oneXRP = new RippleCurrency(1.0m);
RippleTransaction tx =
new RipplePaymentTransaction
{
Destination = dest,
Account = address,
Amount = oneXRP
};
Sign and submit the transaction
tx.AutoRequestFee(
network,
token);
tx.AutoRequestSequence(
address,
network,
token);
RippleIdentifier secret = new RippleSeedAddress("the secret");
tx.SignLocalRippled(secret);
tx.SignRippleDotNet(secret);
tx.SignRippleLibSharp(secret);
Response<RippleSubmitTxResult> submitTask = tx.Submit(network, token);
var outcome = submitTask.result;
Console.WriteLine(
outcome.engine_result );