Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Your seed is an 81 char TRYTE string. The Tryte alphabet is upper care A-Z and 9. Use a tool to create your own seed.
            // The seed below is the full alphabet repeated 3 times. NEVER user this seed to transfer Iota as your IOTA will not be safe.
            var seed = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9";

            // Get an address without hitting the Internet.
            var address1 = BeeFrog.Iota.Api.Utils.IotaUtils.GenerateAddress(seed, 0);

            Console.WriteLine($"Your address is: {address1.Address}");

            var api = new IotaApi("https://nodes.thetangle.org/");

            // Get one address.
            Console.WriteLine($"Creating an address and checking it's balance.");
            var address1WithBalance = api.GetAddress(seed, 0).Result;

            Console.WriteLine($"Your address is: {address1WithBalance.Address} Your balance is: {address1WithBalance.Balance} Iota");

            // Get multiple address.
            Console.WriteLine($"Getting 3 addresses and checking their balance.");
            var addresses = api.GetAddresses(seed, 1, 3, CancellationToken.None).Result;

            foreach (var address in addresses)
            {
                Console.WriteLine($"Another address is: {address.Address} Your balance is: {address.Balance} Iota");
            }

            Console.WriteLine($"Press any key to close");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Connecting to a Node!");

            // !!Use a secure seed!! not this one!
            var seed = "CBM9PSNQPZVDXCHYJXDKUQITXAWQPBWZGYTBGTEIFWXOZTMHESEVHYLXWASWQFEJHUAKHIKSCA9AL9KMG";

            var api = new IotaApi(Url, 14);

            var address1 = api.GetAddress(seed, 0).Result;

            Console.WriteLine("your first address:" + address1.Address);

            var address2 = api.GetAddress(seed, 1).Result;

            Console.WriteLine("your second address:" + address2.Address);

            var stopwatch = Stopwatch.StartNew();
            // Sending a message without using any funds.
            var transfer = new TransferItem()
            {
                Address = address2.Address,
                Value   = 0,
                Message = "MY9FIRST9MESSAGE",
                Tag     = "TAGGOESHERE"
            };

            var transactionItem = api.AttachTransfer(transfer, CancellationToken.None).Result;

            Console.WriteLine($"You transaction took: {stopwatch.Elapsed.TotalSeconds} seconds.");
            Console.WriteLine($"Your transaction hash (might be):  {transactionItem[0].Hash}");


            Console.WriteLine($"Press any key to exit");
            Console.ReadKey();
        }