private static async Task MainAsync(string[] args) { string nodeBaseUrl = "http://localhost:64149"; INodeClient nodeClient = new NodeClient(nodeBaseUrl); CreateTransactionRequest request = CreateAndSignTransaction( "7e4670ae70c98d24f3662c172dc510a085578b9ccc717e6c2f4e547edd960a34", "f51362b7351ef62253a227a77751ad9b2302f911", "2018-02-10T17:53:48.972Z", 25000, 10, "funds"); Response <Transaction> resposne = await nodeClient.CreateTransaction(request).ConfigureAwait(false); Console.WriteLine(resposne.Status); VerifyTransaction(request); }
public static async Task CreateAndSignFaucetTransaction(string recipientAddress, long value) { Console.WriteLine("--------------------------------"); Console.WriteLine("CREATING TRANSACTION FROM FAUCET"); Console.WriteLine("--------------------------------\n"); string dateTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); TransactionData transactionData = new TransactionData { From = faucetAddress, To = recipientAddress, Value = value, Fee = 10, DateCreated = dateTime, Data = "faucetTX", SenderPubKey = faucetPublicKey }; string transactionJson = JsonUtils.Serialize(transactionData, false); Console.WriteLine("Transaction (JSON): {0}\n\n", transactionJson); byte[] transactionDataHash = HashUtils.ComputeSha256(transactionJson.GetBytes()); var tranSignature = EncryptionUtils.Sign(transactionDataHash, faucetPrivateKey); CreateTransactionRequest signedTransaction = CreateTransactionRequest.FromTransactionData(transactionData); signedTransaction.SenderSignature = new string[] { tranSignature[0].ToString(16), tranSignature[1].ToString(16) }; string signedTranJson = JsonUtils.Serialize(signedTransaction); Console.WriteLine("\nSigned transaction (JSON):"); Console.WriteLine(signedTranJson); var nodeClient = new NodeClient("http://localhost:64149"); Response <Transaction> response; int retries = 0; do { response = await nodeClient.CreateTransaction(signedTransaction).ConfigureAwait(false); retries++; } while (response.Status == Status.Failed && retries <= 5); if (response.Status == Status.Success) { Console.WriteLine("Transaction submitted to blockchain!"); } else { Console.WriteLine("Transaction unsuccessful!"); foreach (var error in response.Errors) { Console.WriteLine($"Error: {error}"); } } }