Exemplo n.º 1
0
        private static ExecutionState Runtime_IsMinter(RuntimeVM vm)
        {
            try
            {
                var tx = vm.Transaction;
                Throw.IfNull(tx, nameof(tx));

                vm.ExpectStackSize(1);

                var address = vm.PopAddress();
                var symbol  = vm.PopString("symbol");

                bool success = vm.IsMintingAddress(address, symbol);

                var result = new VMObject();
                result.SetValue(success);
                vm.Stack.Push(result);
            }
            catch (Exception e)
            {
                throw new VMException(vm, e.Message);
            }

            return(ExecutionState.Running);
        }
Exemplo n.º 2
0
        private static ExecutionState Runtime_MintTokens(RuntimeVM vm)
        {
            vm.ExpectStackSize(4);

            var source      = vm.PopAddress();
            var destination = vm.PopAddress();

            var symbol = vm.PopString("symbol");
            var amount = vm.PopNumber("amount");

            if (vm.Nexus.HasGenesis)
            {
                var isMinter = vm.IsMintingAddress(source, symbol);
                vm.Expect(isMinter, $"{source} is not a valid minting address for {symbol}");
            }

            vm.MintTokens(symbol, source, destination, amount);

            return(ExecutionState.Running);
        }