//查询余额 async Task test_BalanceOf() { Console.WriteLine("Input target address (" + this.address + "):"); string addr; try { addr = Console.ReadLine(); if (addr == "\n") { addr = this.address; } } catch (Exception e) { addr = this.address; } byte[] hash = ThinNeo.Helper.GetPublicKeyHashFromAddress(addr); string strhash = ThinNeo.Helper.Bytes2HexString(hash); var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "balanceOf", "(bytes)" + strhash); sdusd_common2.ResultItem item = result.value; Console.WriteLine(item.subItem[0].AsInteger()); }
async Task test_totalGenerate() { var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "totalGenerate", null); sdusd_common2.ResultItem item = result.value; Console.WriteLine(item.subItem[0].AsInteger()); }
//查询需要赎回余额 async Task test_balanceOfRedeem() { var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "balanceOfRedeem", "(addr)" + this.address); sdusd_common2.ResultItem item = result.value; Console.WriteLine(item.subItem[0].AsInteger()); }
//查询标志 async Task test_symbol() { var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "symbol", null); sdusd_common2.ResultItem item = result.value; Console.WriteLine(item.subItem[0].AsString()); }
//查询配置信息 async Task test_getConfig() { Console.WriteLine("Input config key:"); string key = Console.ReadLine(); var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "getConfig", "(str)" + key); sdusd_common2.ResultItem item = result.value; Console.WriteLine(item.subItem[0].AsInteger()); }
//查询交易信息 async Task test_getTXInfo() { Console.WriteLine("Input txid:"); string txid = Console.ReadLine(); var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "getTXInfo", "(hex256)" + txid); sdusd_common2.ResultItem item = result.value; sdusd_common2.ResultItem[] items = item.subItem[0].subItem; //查询交易详细信息 Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160())); Console.WriteLine("to:" + ThinNeo.Helper.GetAddressFromScriptHash(items[1].AsHash160())); Console.WriteLine("value:" + items[2].AsInteger()); }
//查询CDP交易信息 async Task test_getCdp() { Console.WriteLine("Input address:"); string address = Console.ReadLine(); var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "getCDP", "(addr)" + address); sdusd_common2.ResultItem item = result.value; sdusd_common2.ResultItem[] items = item.subItem[0].subItem; if (items != null) { Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160())); Console.WriteLine("txid:" + items[1].AsHashString()); Console.WriteLine("locked:" + items[2].AsInteger()); Console.WriteLine("hasDrawed:" + items[3].AsInteger()); } else { Console.WriteLine("no cdp exists"); } }
//查询CDP详细交易信息 async Task test_getCdpTxInfo() { Console.WriteLine("Input txid:"); string txid = Console.ReadLine(); var result = await sdusd_common2.api_InvokeScript(sdusd_common2.sc_sdusd, "getCdpTxInfo", "(hex256)" + txid); sdusd_common2.ResultItem item = result.value; sdusd_common2.ResultItem[] items = item.subItem[0].subItem; if (items != null) { Console.WriteLine("from:" + ThinNeo.Helper.GetAddressFromScriptHash(items[0].AsHash160())); Console.WriteLine("cdpTxid:" + items[1].AsHashString()); Console.WriteLine("txid:" + items[2].AsHashString()); Console.WriteLine("operated:" + items[3].AsInteger()); Console.WriteLine("hasLocked:" + items[4].AsInteger() + " PNEO"); Console.WriteLine("hasDrawed:" + items[5].AsInteger() + " SDUSD"); Console.WriteLine("type:" + items[6].AsInteger()); } else { Console.WriteLine("no txInfo exists"); } }