首先需要安装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

反编译以后的文件如下:

Solidity原理(六):用solc编译smart contract,用evm反编译bytecode

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

solc还有下面几个非常好用的指令,可以获得合约的ast,asm(汇编码),opcode,bin,abi,函数签名等

Solidity原理(六):用solc编译smart contract,用evm反编译bytecode

相关文章:

  • 2021-11-04
  • 2022-01-16
  • 2021-12-05
  • 2021-04-13
  • 2021-11-07
  • 2021-10-20
  • 2021-08-26
  • 2021-09-03
猜你喜欢
  • 2021-11-02
  • 2021-04-27
  • 2021-11-23
  • 2021-11-26
  • 2021-04-21
  • 2021-04-12
  • 2021-09-30
相关资源
相似解决方案