EVM Bytecode Decompiler
An Ethereum Virtual Machine (EVM) interpreter and decompiler, along with several other utils for programmatically extracting information from bytecode.
Usage
npm i evm
Features
- Converting bytecode to opcodes
- Reading information like events or functions from either bytecode or tx data
- Extracting the swarm hash (if any) from bytecode
API
Methods
- getBytecode() - Get raw bytecode (not really useful; same as input)
- getOpcodes() - Returns opcodes including pc and pushData (if included)
- getFunctions() - Parse functions from their signatures in bytecode
- getEvents() - Parse events from their signatures in bytecode
- getJumpDestinations() - Get array of program counters from JUMPDEST opcodes
- getSwarmHash() - Get Swarm hash (if any) for contract metadata
- reset() - Reset the EVM state (stack, memory, etc.)
- parse() - Interpret opcodes by looping over them, returns array of interpreted opcodes
- decompile() - Decompile bytecode into readable Solidity-like pseudocode
Examples
Converting bytecode to opcodes
Node.js
const EVM = ;const Web3 = ;const web3 = "https://api.mycryptoapi.com/eth"; web3eth;
Browser
const EVM = windowEVM_Utils;const web3 = windowweb3currentProvider;web3eth;
Decompiling a contract
Node.js
const EVM = ;const Web3 = ;const web3 = "https://api.mycryptoapi.com/eth"; web3eth;
Browser
const EVM = windowEVM;const web3 = windowweb3currentProvider;web3eth;
Extracting data from transaction
Node.js
const Transaction = ;const Web3 = ;const web3 = "https://api.mycryptoapi.com/eth"; web3eth;
Browser
const Transaction = windowEVM;const web3 = windowweb3currentProvider;web3eth;