public static async Task <List <(string, int)> > MintNFTTicketsFromTemplate(NeblioAccount account, string templateFileName)
        {
            if (!FileHelpers.IsFileExists(templateFileName))
            {
                throw new Exception("Input file does not exists.");
            }

            var templateData   = FileHelpers.ReadTextFromFile(templateFileName);
            var ticketTemplate = new PlaneTicketsTemplate();

            try
            {
                ticketTemplate = JsonConvert.DeserializeObject <PlaneTicketsTemplate>(templateData);
            }
            catch (Exception ex)
            {
                throw new Exception("Cannot deserialize the template data." + ex.Message);
            }
            var output = new List <(string, int)>();

            foreach (var section in ticketTemplate.Sections)
            {
                foreach (var coulmn in section.ColumnsMarks)
                {
                    for (var i = 0; i < section.NumberOfRows; i++)
                    {
                        var nft = new TicketNFT("");
                        nft.Author              = ticketTemplate.AerolinesName;
                        nft.Name                = "Flight:" + ticketTemplate.FlightNumber;
                        nft.Description         = $"Flight: {ticketTemplate.FlightNumber} to {ticketTemplate.Location}";
                        nft.Tags                = "planeticket";
                        nft.Link                = ticketTemplate.AerolinesWebsite;
                        nft.AuthorLink          = ticketTemplate.AerolinesWebsite;
                        nft.EventId             = ticketTemplate.FlightNumber;
                        nft.EventDate           = ticketTemplate.StartOfFlight;
                        nft.Location            = ticketTemplate.Location;
                        nft.LocationCoordinates = ticketTemplate.StartLocationCoordinates;
                        nft.Seat                = $"Column: {coulmn}, Row: {i}";
                        nft.Price               = section.PriceInNeblio;
                        nft.DogePrice           = section.PriceInDoge;
                        nft.TicketClass         = section.SectionClass;
                        nft.VideoLink           = ticketTemplate.SafetyVideoLink;
                        nft.ImageLink           = ticketTemplate.AerolinesLogo;
                        var done = false;
                        while (!done)
                        {
                            var res = await account.MintNFT(nft);

                            done = res.Item1;
                            if (!done)
                            {
                                Console.WriteLine("Waiting for spendable utxo...");
                                await Task.Delay(5000);
                            }
                            else
                            {
                                output.Add((res.Item2, 0));
                            }
                        }
                    }
                }
            }
            return(output);
        }
Beispiel #2
0
        private static async Task MintNFT()
        {
            Console.WriteLine("Minting NFT");
            // create NFT object
            var nft = new ImageNFT("");

            Console.WriteLine("Fill name:");
            var data = Console.ReadLine();

            if (!string.IsNullOrEmpty(data))
            {
                nft.Name = data;
            }
            else
            {
                nft.Name = "My First NFT";
            }

            Console.WriteLine("Fill Author:");
            data = Console.ReadLine();
            if (!string.IsNullOrEmpty(data))
            {
                nft.Author = data;
            }
            else
            {
                nft.Author = "fyziktom";
            }

            Console.WriteLine("Fill Description:");
            data = Console.ReadLine();
            if (!string.IsNullOrEmpty(data))
            {
                nft.Description = data;
            }
            else
            {
                nft.Description = "This was created with VEDriversLite";
            }

            Console.WriteLine("Fill Link:");
            data = Console.ReadLine();
            if (!string.IsNullOrEmpty(data))
            {
                nft.Link = data;
            }
            else
            {
                nft.Link = "https://veframework.com/";
            }

            Console.WriteLine("Fill Image Link:");
            data = Console.ReadLine();
            if (!string.IsNullOrEmpty(data))
            {
                nft.ImageLink = data;
            }
            else
            {
                nft.ImageLink = "https://gateway.ipfs.io/ipfs/QmWTkVqaWn1ABZ1UMKL91pxxspzXW6yodJ9bjUn6nPLeHX";
            }

            // send 10 VENFT to receiver with connected metadata
            var res = await account.MintNFT(nft);

            // or multimint with 5 coppies (mint 1 + 5);
            // var res = await account.MintMultiNFT(NFTHelpers.TokenId, nft, 5);
            Console.WriteLine("New TxId hash is: ");
            Console.WriteLine(res);
        }