Evm

你能告訴我如何使用 Executables evm 嗎?

  • July 25, 2018

我使用的契約如下:

pragma solidity ^0.4.0;
contract TestContract
{
function multiply(uint a, uint b) returns (uint)
   {
       return a * b;
   }
}

solc --bin-runtime TestContract.sol獲取其執行時程式碼。

然後evm --code 0x[runtimecode] --input 0x165c4a1600000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000007執行(輸入值來自 Remix 和 solc –hashes xxx.sol ,輸入參數 5,7)

但是 cmd 中顯示的結果是 0x 。怎麼了?如果部署在私有鏈中並執行本地方法,它將返回正確答案 35。

合約程式碼

contract TestContract
{
function multiply(uint a, uint b) public pure returns (uint)
   {
       return a*b;
   }
}

然後

solc --bin-runtime TestContract.sol :

======= test.sol:TestContract =======
Binary of the runtime part: 
608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063165c4a16146044575b600080fd5b348015604f57600080fd5b5060766004803603810190808035906020019092919080359060200190929190505050608c565b6040518082815260200191505060405180910390f35b60008183029050929150505600a165627a7a72305820b321ef9f385622373dd6ff8a6ee31a7ead7dbccb991373435cef33b0526fd3110029

然後呼叫evm

evm --code 608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063165c4a16146044575b600080fd5b348015604f57600080fd5b5060766004803603810190808035906020019092919080359060200190929190505050608c565b6040518082815260200191505060405180910390f35b60008183029050929150505600a165627a7a72305820b321ef9f385622373dd6ff8a6ee31a7ead7dbccb991373435cef33b0526fd3110029 --input 165c4a1600000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000007 run

您的錯誤是使用帶有 0x 的 calldata

輸出結果是

0x0000000000000000000000000000000000000000000000000000000000000023

在此處輸入圖像描述

引用自:https://ethereum.stackexchange.com/questions/55122