static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); Console.WriteLine("Waiting for events..."); var ret = client.SmartContractEventsSubscribe("AmhcceopRiU7r3Gwy5tmtkk4Z3Px53SfsKBifGMvaSSNiyWrvKYe", string.Empty, Callback, new AergoClient.CallbackState()); while (client.ProcessRequests(5000) > 0) /* repeat */ } { } }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); AergoClient.AergoAccount account = new AergoClient.AergoAccount { privkey = new byte[] { 0xDB, 0x85, 0xDD, 0x0C, 0xBA, 0x47, 0x32, 0xA1, 0x1A, 0xEB, 0x3C, 0x7C, 0x48, 0x91, 0xFB, 0xD2, 0xFE, 0xC4, 0x5F, 0xC7, 0x2D, 0xB3, 0x3F, 0xB6, 0x1F, 0x31, 0xEB, 0x57, 0xE7, 0x24, 0x61, 0x76 } }; /* or use an account on Ledger Nano S */ //AergoClient.AergoAccount account = new AergoClient.AergoAccount //{ // use_ledger = true //}; var context = new AergoClient.CallbackState() { data = "any object can be set here as context" }; Console.WriteLine("Calling Smart Contract Function..."); var ret = client.CallSmartContractAsync(ReceiptReceived, context, ref account, "AmgLnRaGFLyvCPCEMHYJHooufT1c1pENTRGeV78WNPTxwQ2RYUW7", "set_name", "C# App"); if (ret) { Console.WriteLine("Waiting for response.."); while (client.ProcessRequests(5000) > 0) { // loop } } else { Console.WriteLine("Failed to send the transaction"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); AergoClient.AergoAccount account = new AergoClient.AergoAccount { privkey = new byte[] { 0xDB, 0x85, 0xDD, 0x0C, 0xBA, 0x47, 0x32, 0xA1, 0x1A, 0xEB, 0x3C, 0x7C, 0x48, 0x91, 0xFB, 0xD2, 0xFE, 0xC4, 0x5F, 0xC7, 0x2D, 0xB3, 0x3F, 0xB6, 0x1F, 0x31, 0xEB, 0x57, 0xE7, 0x24, 0x61, 0x76 } }; /* or use an account on Ledger Nano S */ //AergoClient.AergoAccount account = new AergoClient.AergoAccount //{ // use_ledger = true //}; Console.WriteLine("Calling Smart Contract..."); AergoClient.TransactionReceipt receipt = client.CallSmartContract(ref account, "AmgLnRaGFLyvCPCEMHYJHooufT1c1pENTRGeV78WNPTxwQ2RYUW7", "set_name", "C# App"); if (receipt.Sent) { Console.WriteLine("--- Transaction Receipt ---"); Console.WriteLine("Status : " + receipt.status); Console.WriteLine("ret : " + receipt.ret); Console.WriteLine("BlockNo: " + receipt.blockNo); Console.WriteLine("TxIndex: " + receipt.txIndex); Console.WriteLine("GasUsed: " + receipt.gasUsed); } else { Console.WriteLine("Failed to send the transaction"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); AergoClient.AergoAccount account = new AergoClient.AergoAccount { privkey = new byte[] { 0xDB, 0x85, 0xDD, 0x0C, 0xBA, 0x47, 0x32, 0xA1, 0x1A, 0xEB, 0x3C, 0x7C, 0x48, 0x91, 0xFB, 0xD2, 0xFE, 0xC4, 0x5F, 0xC7, 0x2D, 0xB3, 0x3F, 0xB6, 0x1F, 0x31, 0xEB, 0x57, 0xE7, 0x24, 0x61, 0x76 } }; /* or an the account on Ledger Nano S */ //AergoClient.AergoAccount account = new AergoClient.AergoAccount //{ // use_ledger = true //}; Console.WriteLine("Sending request..."); var ret = client.GetAccountInfo(ref account); if (ret.success) { Console.WriteLine("Account state:"); Console.WriteLine("Address = " + account.address); Console.WriteLine("Balance = " + account.balance); Console.WriteLine("Nonce = " + account.nonce); } else { Console.WriteLine("Failed: " + ret.error); } } Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); Console.WriteLine("Sending request..."); var context = new AergoClient.CallbackState() { data = "you can pass any object to the callback here" }; var lResult = client.QuerySmartContractAsync(QueryCallback, context, "AmgLnRaGFLyvCPCEMHYJHooufT1c1pENTRGeV78WNPTxwQ2RYUW7", "hello", null); if (lResult) { Console.WriteLine("Done. Waiting for response..."); while (client.ProcessRequests(5000) > 0) /* repeat */ } { }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); Console.WriteLine("Querying Smart Contract..."); var ret = client.QuerySmartContract("AmgLnRaGFLyvCPCEMHYJHooufT1c1pENTRGeV78WNPTxwQ2RYUW7", "hello"); if (!ret.success) { Console.WriteLine("Error: " + ret.result); } else { Console.WriteLine("Result: " + ret.result); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); AergoClient.AergoAccount account = new AergoClient.AergoAccount { privkey = new byte[] { 0xDB, 0x85, 0xDD, 0x0C, 0xBA, 0x47, 0x32, 0xA1, 0x1A, 0xEB, 0x3C, 0x7C, 0x48, 0x91, 0xFB, 0xD2, 0xFE, 0xC4, 0x5F, 0xC7, 0x2D, 0xB3, 0x3F, 0xB6, 0x1F, 0x31, 0xEB, 0x57, 0xE7, 0x24, 0x61, 0x76 } }; AergoClient.TransactionReceipt receipt; // Value as double receipt = client.Transfer(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", 0.15); if (receipt.Sent) { Console.WriteLine("--- Transaction Receipt ---"); Console.WriteLine("Status : " + receipt.status); Console.WriteLine("ret : " + receipt.ret); Console.WriteLine("BlockNo: " + receipt.blockNo); Console.WriteLine("TxIndex: " + receipt.txIndex); Console.WriteLine("GasUsed: " + receipt.gasUsed); } else { Console.WriteLine("Failed to send the transfer"); } // Value as string receipt = client.Transfer(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", "0.25"); if (receipt.Sent) { Console.WriteLine("--- Transaction Receipt ---"); Console.WriteLine("Status : " + receipt.status); Console.WriteLine("ret : " + receipt.ret); Console.WriteLine("BlockNo: " + receipt.blockNo); Console.WriteLine("TxIndex: " + receipt.txIndex); Console.WriteLine("GasUsed: " + receipt.gasUsed); } else { Console.WriteLine("Failed to send the transfer"); } // Value as integer and decimal parts receipt = client.Transfer(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", 1, 350000000000000000); if (receipt.Sent) { Console.WriteLine("--- Transaction Receipt ---"); Console.WriteLine("Status : " + receipt.status); Console.WriteLine("ret : " + receipt.ret); Console.WriteLine("BlockNo: " + receipt.blockNo); Console.WriteLine("TxIndex: " + receipt.txIndex); Console.WriteLine("GasUsed: " + receipt.gasUsed); } else { Console.WriteLine("Failed to send the transfer"); } // Value as BigInteger receipt = client.Transfer(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", new BigInteger(1450000000000000000)); if (receipt.Sent) { Console.WriteLine("--- Transaction Receipt ---"); Console.WriteLine("Status : " + receipt.status); Console.WriteLine("ret : " + receipt.ret); Console.WriteLine("BlockNo: " + receipt.blockNo); Console.WriteLine("TxIndex: " + receipt.txIndex); Console.WriteLine("GasUsed: " + receipt.gasUsed); } else { Console.WriteLine("Failed to send the transfer"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }
static void Main(string[] args) { using (AergoClient client = new AergoClient()) { client.Connect("testnet-api.aergo.io", 7845); AergoClient.AergoAccount account = new AergoClient.AergoAccount { privkey = new byte[] { 0xDB, 0x85, 0xDD, 0x0C, 0xBA, 0x47, 0x32, 0xA1, 0x1A, 0xEB, 0x3C, 0x7C, 0x48, 0x91, 0xFB, 0xD2, 0xFE, 0xC4, 0x5F, 0xC7, 0x2D, 0xB3, 0x3F, 0xB6, 0x1F, 0x31, 0xEB, 0x57, 0xE7, 0x24, 0x61, 0x76 } }; AergoClient.CallbackState context; bool ret; Console.WriteLine("Sending transfers..."); context = new AergoClient.CallbackState() { data = "double" }; ret = client.TransferAsync(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", 0.15, ReceiptReceived, context); if (ret == false) { Console.WriteLine("Failed with " + context.data); } context = new AergoClient.CallbackState() { data = "integer and decimal" }; ret = client.TransferAsync(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", 1, 250000000000000000, ReceiptReceived, context); if (ret == false) { Console.WriteLine("Failed with " + context.data); } context = new AergoClient.CallbackState() { data = "string" }; ret = client.TransferAsync(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", "0.35", ReceiptReceived, context); if (ret == false) { Console.WriteLine("Failed with " + context.data); } context = new AergoClient.CallbackState() { data = "BigInteger" }; ret = client.TransferAsync(ref account, "AmQFpC4idVstgqhnn7ihyueadTBVBq55LzDLbK8XbzHuhMxKAQ72", new BigInteger(1450000000000000000), ReceiptReceived, context); if (ret == false) { Console.WriteLine("Failed with " + context.data); } Console.WriteLine("Waiting for the receipts..."); while (client.ProcessRequests(5000) > 0) /* repeat */ } { Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }