1. 程式人生 > >Solidity原理(六):用solc編譯smart contract,用evm反編譯bytecode

Solidity原理(六):用solc編譯smart contract,用evm反編譯bytecode

首先需要安裝solc和evm

solc: https://github.com/ethereum/solidity/releases

evm:   https://geth.ethereum.org/downloads/

編譯一個smart contract可以通過指令 solc --bin-runtime filepath來得到bytecode

反編譯bytecode可以通過evm --dissam bytecodeFilePath

反編譯以後的檔案如下:


前面的數字就是pc(programmer counter), 以20行的指令為例,0x008d代表21行的JUMPI跳轉的pc值是141. 

solc還有下面幾個非常好用的指令,可以獲得合約的ast,asm(彙編碼),opcode,bin,abi,函式簽名等