Esempio n. 1
0
        public static void Main()
        {
            var service  = new MonetarySystemService();
            var currency = service.GetCurrency(CurrencyLocator.ByCurrencyId(7851677590592900934)).Result;
            var founders = service.GetCurrencyFounders(7851677590592900934).Result;

            var goal          = currency.ReserveSupply * currency.MinReservePerUnit.Nxt;
            var reservedTotal = founders.Founders.Sum(f => f.AmountPerUnit.Nxt) * currency.ReserveSupply;

            var nfi = new System.Globalization.NumberFormatInfo
            {
                NumberDecimalSeparator = ".",
                CurrencyGroupSeparator = ","
            };

            Console.WriteLine($"Name:         {currency.Name}");
            Console.WriteLine($"Code:         {currency.Code}");
            Console.WriteLine($"Id:           {currency.CurrencyId}");
            Console.WriteLine(string.Format(nfi, "Reserve Goal: {0:0,0.0} ({1:P})", goal, reservedTotal / goal));
            Console.WriteLine($"Founders:     {founders.Founders.Count}");
            Console.WriteLine("---------------------------------------------------");

            foreach (var founder in founders.Founders.OrderByDescending(f => f.AmountPerUnit.Nqt))
            {
                var reserved = founder.AmountPerUnit.Nxt * currency.ReserveSupply;
                Console.WriteLine(string.Format(nfi, "Account: {0} - {1:0,0.0} NXT", founder.AccountRs, reserved));
            }
            Console.ReadLine();
        }
Esempio n. 2
0
        private static async Task PrintReservableCurrencies()
        {
            var service       = new MonetarySystemService();
            var allCurrencies = await service.GetAllCurrencies();

            var reservableCurrencies = allCurrencies.Currencies
                                       .Where(c => c.Types.Contains(CurrencyType.Reservable))
                                       .OrderBy(c => c.Name)
                                       .ToList();

            Console.WriteLine("** Listing of all reservable currencies **");
            Console.WriteLine("");
            var total = 0M;

            foreach (var currency in reservableCurrencies)
            {
                var founders = await service.GetCurrencyFounders(currency.CurrencyId);

                var goal = currency.ReserveSupply * currency.MinReservePerUnit.Nxt;

                Console.WriteLine("----------------------------");
                Console.WriteLine($"Name: {currency.Name}");
                Console.WriteLine($"Founders: {founders.Founders.Count}");
                Console.WriteLine($"Reserve Goal: {goal:n} NXT");
                if (founders.Founders.Count > 0)
                {
                    var reserverdPerUnitNxt = founders.Founders.Sum(f => f.AmountPerUnit.Nxt);
                    var reservedNxt         = reserverdPerUnitNxt * currency.ReserveSupply;

                    total += reservedNxt;
                    Console.WriteLine($"Amount: {reservedNxt:n} NXT ({reservedNxt / goal:P})");
                }
                Console.WriteLine("");
            }

            Console.WriteLine("----------------------------");
            Console.WriteLine($"Total reserved: {total:n} NXT");
            Console.WriteLine("");
            Console.WriteLine("Press any key to quit");
            Console.ReadLine();
        }
Esempio n. 3
0
        public static void Main()
        {
            var monetarySystemService   = new MonetarySystemService();
            var transactionService      = new TransactionService();
            var localTransactionService = new LocalTransactionService();

            // Get the unsigned transaction bytes from the NRS server
            var parameters = new CreateTransactionByPublicKey(1440, Amount.Zero, SenderPublicKey);
            var unsigned   = monetarySystemService.TransferCurrency(Recipient, CurrencyId, Units, parameters).Result;

            // Verify the unsigned transaction bytes from the node, will throw exception if bytes have been tampered with
            localTransactionService.VerifyTransferCurrencyTransactionBytes(unsigned, parameters, Recipient, CurrencyId, Units);

            // Sign the transaction locally and broadcast the signed bytes
            var signed        = localTransactionService.SignTransaction(unsigned, SecretPhrase);
            var result        = transactionService.BroadcastTransaction(new TransactionParameter(signed.ToString())).Result;
            var transactionId = result.TransactionId;

            Console.WriteLine($"Sent transaction: {transactionId}");

            Console.ReadLine();
        }