public static async Task <string> SignTransaction(KeyPair keyPair, string xdrData) { try { var bytes = Convert.FromBase64String(xdrData); var transEnv = TransactionEnvelope.Decode(new XdrDataInputStream(bytes)); var sourceKP = KeyPair.FromXdrPublicKey(transEnv.Tx.SourceAccount.InnerValue); var server = new Server(horizon_url); var accResponse = await server.Accounts.Account(sourceKP); var source = new Account(sourceKP, accResponse.SequenceNumber); var builder = new stellar_dotnetcore_sdk.Transaction.Builder(source); foreach (var o in transEnv.Tx.Operations) { var operation = PaymentOperation.FromXdr(o); builder.AddOperation(operation); } if (transEnv.Tx.Memo != null && transEnv.Tx.Memo.Text != null) { var m = stellar_dotnetcore_sdk.Memo.Text(transEnv.Tx.Memo.Text); builder.AddMemo(m); } var trans = builder.Build(); trans.Sign(keyPair); var signedXdrData = trans.ToEnvelopeXdrBase64(); return(signedXdrData); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); return(null); } }