コード例 #1
0
        static void Main(string[] args)
        {
            var path = Path.Combine(Directory.GetCurrentDirectory());

            path = Path.GetFullPath(path) + "/.env";
            DotEnv.Config(true, path);
            DotEnv.Config(true, path, Encoding.Unicode, false);
            EnvReader envReader = new EnvReader();

            BlockIo blockIo = new BlockIo(envReader.GetStringValue("API_KEY"), envReader.GetStringValue("PIN"));

            var balance = blockIo.GetBalance().Data.available_balance;

            Console.WriteLine("Balance: " + balance);

            while (true)
            {
                var    res         = blockIo.Withdraw(new { to_address = envReader.GetStringValue("TO_ADDRESS"), amount = balance.ToString() });
                double maxWithdraw = res.Data.max_withdrawal_available;

                Console.WriteLine("Max Withdraw Available: " + maxWithdraw.ToString());

                if (maxWithdraw == 0)
                {
                    break;
                }
                blockIo.Withdraw(new { to_address = envReader.GetStringValue("TO_ADDRESS"), amount = maxWithdraw.ToString() });
            }

            balance = blockIo.GetBalance().Data.available_balance;

            Console.WriteLine("Final Balance: " + balance);
        }
コード例 #2
0
        public void Withdraw()
        {
            pin     = "blockiotestpininsecure";
            blockIo = new BlockIo(api_key, pin, 2, new Options(baseUrl));

            var response = blockIo.Withdraw(withdrawRequestBodyContent);

            Assert.AreEqual("success", response.Status);
            Assert.IsNotNull(response.Data);
        }
コード例 #3
0
        public void RunMaxWithdrawalExample()
        {
            var balance = blockIo.GetBalance().Data.available_balance;

            Console.WriteLine("Balance: " + balance);

            while (true)
            {
                var    res         = blockIo.Withdraw("{to_address: '" + envReader.GetStringValue("TO_ADDRESS") + "', amount: " + balance + "}");
                double maxWithdraw = res.Data.max_withdrawal_available;

                Console.WriteLine("Max Withdraw Available: " + maxWithdraw.ToString());

                if (maxWithdraw == 0)
                {
                    break;
                }
                blockIo.Withdraw("{to_address: '" + envReader.GetStringValue("TO_ADDRESS") + "', amount: " + maxWithdraw + "}");
            }

            balance = blockIo.GetBalance().Data.available_balance;

            Console.WriteLine("Final Balance: " + balance);
        }