Exemplo n.º 1
0
 // Exapnd memory as needed
 private void updateMem(uint256 newSize)
 {
     // Accepting uint256 just for convenience. Should actually use int instead (since int would be sufficient, or long if you prefer)
     m_newMemSize = (newSize + 31) / 32 * 32;
     if (m_newMemSize > m_memory.Count)
     {
         m_memory.AddRange(new byte[(int)m_newMemSize.ToUInt32(false) - m_memory.Count]);
     }
 }
Exemplo n.º 2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 1000; i++)
            {
                for (int j = 0; j < 1000; j++)
                {
                    uint256 a = i;
                    uint256 b = j;
                    uint256 c = a * b;
                    if (i * j != (int)c.ToUInt32())
                    {
                        MessageBox.Show("Error");
                    }
                }
            }


            EVM.DataQuery.EtherscanDataGateway edg = new EVM.DataQuery.EtherscanDataGateway();
            byte[] bytecode = await edg.getCodeAt("0x5d1B26d762b1973B8B7C2bFb196Ba2ED969dAF18");

            // PUSH1 0x05, PUSH1 0x04, RETURN
            EVMInterpreter evm = new EVMInterpreter(bytecode);

            evm.transaction = await edg.getTransactionByHash("0x5f28e503de125f72130269c9f6ef8d456594ef533ff21ce196c89cd0fa0aaca3");

            ShowEVMStatus(evm);

            while (await evm.executeOnce())
            {
                ShowEVMStatus(evm);
            }

            ShowEVMStatus(evm);

            StringBuilder returnStr = new StringBuilder();

            for (int i = 0; i < evm.returnData.Length; i++)
            {
                returnStr.Append(evm.returnData[i].ToString("x2") + (i == evm.returnData.Length - 1 ? "" : ", "));
            }
            Console.WriteLine(string.Format("Return data: [" + returnStr.ToString() + "]"));
        }