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 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(); }
static void EmitCode(Neo.VM.ScriptBuilder builder, ISyntaxNode ast) { if (ast is SyntaxNode_Num) { builder.EmitPush((ast as SyntaxNode_Num).num); } else if (ast is SyntaxNode_Add) { foreach (var sn in ast.subnodes) { EmitCode(builder, sn); } builder.Emit(Neo.VM.OpCode.ADD); } }