Esempio n. 1
0
        async Task test_QueryBalanceOf()
        {
            string path = "D:\\addr2.txt";

            FileStream   fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
            StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);

            string     str = "";
            BigInteger sum = 0;

            while (str != null)
            {
                str = sr.ReadLine();
                Console.WriteLine("address:" + str);
                var result = await sds_common.api_InvokeScript(sds_common.sc_sds, "balanceOf", "(addr)" + str);

                sds_common.ResultItem item = result.value;

                BigInteger mount = item.subItem[0].AsInteger();

                // Console.WriteLine("mount:" + mount);

                sum = sum + mount;
                Thread.Sleep(50);
                Console.WriteLine("total:" + sum);
            }
            sr.Close();
            Console.WriteLine("total:" + sum);
        }
Esempio n. 2
0
        //查询总量
        async Task test_totalSupply()
        {
            var result = await sds_common.api_InvokeScript(sds_common.sc_sds, "totalSupply", null);

            sds_common.ResultItem item = result.value;
            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 3
0
        //查询标志
        async Task test_symbol()
        {
            var result = await sds_common.api_InvokeScript(sds_common.sc_sds, "symbol", null);

            sds_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsString());
        }
Esempio n. 4
0
        //查询最小单位
        async Task test_decimals()
        {
            var result = await sds_common.api_InvokeScript(Config.sds, "decimals", null);

            sds_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 5
0
        //查询名字
        async Task test_name()
        {
            BigInteger sum = 9627308228749 + 2363900000000 + 99956313965785032 + 1175000000000;

            Console.WriteLine(sum);

            var result = await sds_common.api_InvokeScript(sds_common.sc_sds, "name", null);

            sds_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsString());
        }
Esempio n. 6
0
        //查询交易信息
        async Task test_getTXInfo()
        {
            Console.WriteLine("Input txid:");
            string txid   = Console.ReadLine();
            var    result = await sds_common.api_InvokeScript(sds_common.sc_sds, "getTXInfo", "(hex256)" + txid);

            sds_common.ResultItem   item  = result.value;
            sds_common.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());
        }
Esempio n. 7
0
        //批量计算
        async Task test_batchCal2()
        {
            string path = "D:\\address\\balances0801_01.txt";

            FileStream   fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
            StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);

            BigInteger sum = 0;
            string     str = "";

            while (str != null)
            {
                str = sr.ReadLine();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] xu = new String[2];
                    xu = str.Split(',');
                    //转账地址
                    string s = xu[0];
                    //转账金额
                    string m = xu[1];

                    //decimal dmount = decimal.Parse(m);
                    //decimal mount =  dmount * 100000000;
                    ////导出余额
                    //string  mstr =  Math.Round(mount, 0).ToString();
                    BigInteger mountRe = BigInteger.Parse(m);

                    var re = await sds_common.api_InvokeScriptByRPC(sds_common.sc_sds, "balanceOf",
                                                                    "(addr)" + s);

                    sds_common.ResultItem item = re.value;

                    BigInteger mountSrc = item.subItem[0].AsInteger();
                    //Console.WriteLine(s + ","+m);
                    if (mountRe != mountSrc)
                    {
                        Console.WriteLine(s + "/mountSrc:" + mountSrc + "/mountRe:" + mountRe);
                    }
                }
            }
            sr.Close();
        }
Esempio n. 8
0
        //查询余额
        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;
            }

            var result = await sds_common.api_InvokeScript(sds_common.sc_sds, "balanceOf", "(addr)" + addr);

            sds_common.ResultItem item = result.value;

            Console.WriteLine(item.subItem[0].AsInteger());
        }
Esempio n. 9
0
        //查询所有地址
        async Task test_queryAllAddress()
        {
            DateTime dt = DateTime.Now;

            Console.WriteLine("Start time:" + dt);
            byte[] postdata;
            //查询交易,总数可能很多
            var url = Helper.MakeRpcUrlPost(Config.api, "getnep5transfersbyasset", out postdata,
                                            new JsonNode_ValueString(sds_common.sc),
                                            new JsonNode_ValueNumber(10000),
                                            new JsonNode_ValueNumber(1));
            var result = await Helper.HttpPost(url, postdata);

            //System.IO.File.WriteAllText(@"D:\address\addssssss.json", result, Encoding.UTF8);

            List <string> list = new List <string>();

            MyJson.JsonNode_Object json = MyJson.Parse(result) as MyJson.JsonNode_Object;
            JsonNode_Array         arrs = json["result"].AsList();

            foreach (JsonNode_Object ob in arrs)
            {
                string from = ob["from"].AsString();
                string to   = ob["to"].AsString();
                if (!string.IsNullOrEmpty(from))
                {
                    list.Add(from);
                    if (from == to)
                    {
                        Console.WriteLine("from:" + from + "/to:" + to);
                    }
                }
                if (!string.IsNullOrEmpty(to))
                {
                    list.Add(to);
                }
            }
            BigInteger    sum  = 0;
            List <string> adds = list.Distinct().ToList();

            Console.WriteLine("total address:" + adds.Count);
            string[] balances = new string[] { };
            foreach (string s in adds)
            {
                //int index = adds.IndexOf(s);
                //Console.WriteLine("address:" + s);
                //调用RPC
                //var re = await sds_common.api_InvokeScriptByRPC(sds_common.sc_sds, "balanceOf",
                //"(addr)" + s);
                //调用API
                var re = await sds_common.api_InvokeScript(sds_common.sc_sds, "balanceOf",
                                                           "(addr)" + s);

                sds_common.ResultItem item = re.value;

                BigInteger mount = item.subItem[0].AsInteger();
                sum = sum + mount;
                if (mount > 0)
                {
                    //排除掉所有switcheo地址
                    //if (s != "AKJQMHma9MA8KK5M8iQg8ASeg3KZLsjwvB")
                    //{
                    string str     = s + "," + mount + "\r\n";
                    string newPath = @"D:\address\balances0809.txt";
                    File.AppendAllText(newPath, str);
                    //}
                }
            }

            Console.WriteLine("sum:" + sum);
            DateTime end = DateTime.Now;

            Console.WriteLine("End time:" + end);
        }