예제 #1
0
        private static void Mint(BigInteger amount)
        {
            var totalSupply = TotalSupplyStorage.Get();

            if (totalSupply <= 0)
            {
                throw new Exception("Contract not deployed.");
            }

            var avaliable_supply = MaxSupply - totalSupply;

            if (amount <= 0)
            {
                throw new Exception("Amount cannot be zero.");
            }
            if (amount > avaliable_supply)
            {
                throw new Exception("Insufficient supply for mint tokens.");
            }

            Transaction tx = (Transaction)ExecutionEngine.ScriptContainer;

            AssetStorage.Increase(tx.Sender, amount);
            TotalSupplyStorage.Increase(amount);

            OnTransfer(null, tx.Sender, amount);
        }
예제 #2
0
        public static void _deploy(bool update)
        {
            if (update)
            {
                return;
            }
            if (TotalSupplyStorage.Get() > 0)
            {
                throw new Exception("Contract has been deployed.");
            }

            TotalSupplyStorage.Increase(InitialSupply);
            AssetStorage.Increase(Owner, InitialSupply);

            OnTransfer(null, Owner, InitialSupply);
        }
예제 #3
0
 public static BigInteger TotalSupply() => TotalSupplyStorage.Get();