Esempio n. 1
0
        public BigInteger MintToken(string symbol, Address from, Address target, byte[] rom, byte[] ram)
        {
            var Runtime = this;

            Runtime.Expect(Runtime.TokenExists(symbol), "invalid token");
            IToken token;

            using (var m = new ProfileMarker("Runtime.GetToken"))
                token = Runtime.GetToken(symbol);
            Runtime.Expect(!token.IsFungible(), "token must be non-fungible");
            // TODO should not be necessary, verified by trigger
            //Runtime.Expect(IsWitness(target), "invalid witness");

            Runtime.Expect(Runtime.IsRootChain(), "can only mint nft in root chain");

            Runtime.Expect(rom.Length <= TokenContent.MaxROMSize, "ROM size exceeds maximum allowed");
            Runtime.Expect(ram.Length <= TokenContent.MaxRAMSize, "RAM size exceeds maximum allowed");

            BigInteger tokenID;

            using (var m = new ProfileMarker("Nexus.CreateNFT"))
                tokenID = Nexus.CreateNFT(this, symbol, Runtime.Chain.Name, target, rom, ram);
            Runtime.Expect(tokenID > 0, "invalid tokenID");

            using (var m = new ProfileMarker("Nexus.MintToken"))
                Nexus.MintToken(this, token, from, target, Chain.Name, tokenID, rom, ram);

            return(tokenID);
        }