private static ExecutionState Nexus_CreateToken(RuntimeVM vm) { vm.ExpectStackSize(7); var owner = vm.PopAddress(); var symbol = vm.PopString("symbol"); var name = vm.PopString("name"); var maxSupply = vm.PopNumber("maxSupply"); var decimals = (int)vm.PopNumber("decimals"); var flags = vm.PopEnum <TokenFlags>("flags"); var script = vm.PopBytes("script"); ContractInterface abi; if (vm.ProtocolVersion >= 4) { var abiBytes = vm.PopBytes("abi bytes"); abi = ContractInterface.FromBytes(abiBytes); } else { abi = new ContractInterface(); } vm.CreateToken(owner, symbol, name, maxSupply, decimals, flags, script, abi); return(ExecutionState.Running); }
private static ExecutionState Runtime_CreateToken(RuntimeVM Runtime) { ExpectStackSize(Runtime, 7); VMObject temp; var source = PopAddress(Runtime); temp = Runtime.Stack.Pop(); Runtime.Expect(temp.Type == VMType.String, "expected string for symbol"); var symbol = temp.AsString(); temp = Runtime.Stack.Pop(); Runtime.Expect(temp.Type == VMType.String, "expected string for name"); var name = temp.AsString(); /* * temp = Runtime.Stack.Pop(); * Runtime.Expect(temp.Type == VMType.String, "expected string for platform"); * var platform = temp.AsString(); * * temp = Runtime.Stack.Pop(); * Runtime.Expect(temp.Type == VMType.Bytes, "expected bytes for hash"); * var hash = Serialization.Unserialize<Hash>(temp.AsByteArray());*/ temp = Runtime.Stack.Pop(); Runtime.Expect(temp.Type == VMType.Number, "expected number for maxSupply"); var maxSupply = temp.AsNumber(); temp = Runtime.Stack.Pop(); Runtime.Expect(temp.Type == VMType.Number, "expected number for decimals"); var decimals = (int)temp.AsNumber(); temp = Runtime.Stack.Pop(); Runtime.Expect(temp.Type == VMType.Enum, "expected enum for flags"); var flags = temp.AsEnum <TokenFlags>(); temp = Runtime.Stack.Pop(); Runtime.Expect(temp.Type == VMType.Bytes, "expected bytes for script"); var script = temp.AsByteArray(); Runtime.CreateToken(source, symbol, name, maxSupply, decimals, flags, script); return(ExecutionState.Running); }