Beispiel #1
0
        static void Main(string[] args)
        {
            Neo.VM.ScriptBuilder builder = new Neo.VM.ScriptBuilder();

            builder.Emit(Neo.VM.OpCode.NOP);
            builder.EmitPush(1);
            builder.EmitPush(2);
            builder.Emit(Neo.VM.OpCode.ADD);
            builder.Emit(Neo.VM.OpCode.RET);

            var machinecode = builder.ToArray();
            var hexstr      = "0x";

            foreach (var m in machinecode)
            {
                hexstr += m.ToString("X02");
            }
            Console.WriteLine("machinecode=" + hexstr);

            //run machinecode with neovm
            var engine = new Neo.VM.ExecutionEngine();

            engine.LoadScript(machinecode);
            engine.Execute();

            //show result
            var calcstack = engine.ResultStack;

            var v = calcstack.Peek();

            Console.WriteLine("retvalue=" + v.GetBigInteger());

            Console.ReadLine();
        }
            static byte[] BuildInvokeScript(UInt160 scriptHash, IEnumerable <ContractArgument> arguments)
            {
                using var builder = new Neo.VM.ScriptBuilder();
                foreach (var argument in arguments.Reverse())
                {
                    argument.EmitPush(builder);
                }

                builder.EmitAppCall(scriptHash);
                return(builder.ToArray());
            }
Beispiel #3
0
        static void Main(string[] args)
        {
            var noparamAVM = System.IO.File.ReadAllBytes("/Users/gianca/Projects/junction/junction/bin/Debug/netstandard2.0/junction.avm");
            var str        = Neo.Helper.ToHexString(noparamAVM);

            Neo.VM.ScriptBuilder sb = new Neo.VM.ScriptBuilder();
            sb.EmitPush(new byte[] { 0x13 });
            sb.EmitPush("f**k");
            var _params = sb.ToArray();
            var str2    = Neo.Helper.ToHexString(_params);

            Console.WriteLine("AVM=" + str2 + str);
            Console.ReadLine();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var srccode = " 1 + 2 + 4 + 5";
            var ast     = ParseSyntaxNode(srccode);

            DumpAST(ast);


            Neo.VM.ScriptBuilder builder = new Neo.VM.ScriptBuilder();
            EmitCode(builder, ast);
            builder.Emit(Neo.VM.OpCode.RET);

            var machinecode = builder.ToArray();
            var hexstr      = "0x";

            foreach (var m in machinecode)
            {
                hexstr += m.ToString("X02");
            }
            Console.WriteLine("machinecode=" + hexstr);

            //run machinecode with neovm
            var engine = new Neo.VM.ExecutionEngine();

            engine.LoadScript(machinecode);
            engine.Execute();

            //show result
            var calcstack = engine.ResultStack;

            var v = calcstack.Peek();

            Console.WriteLine("retvalue=" + v.GetBigInteger());

            Console.ReadLine();
        }
Beispiel #5
0
 public static ApplicationEngine Invoke(this Neo.VM.ScriptBuilder builder, ProtocolSettings settings, DataCache snapshot) => Invoke(builder.ToArray(), settings, snapshot);
Beispiel #6
0
 public static ApplicationEngine Invoke(this Neo.VM.ScriptBuilder builder, ProtocolSettings settings, DataCache snapshot, IVerifiable?container = null)
 => Invoke(builder.ToArray(), settings, snapshot, container);