{"id":19340145,"url":"https://github.com/mrluit/evm","last_synced_at":"2025-04-06T01:06:07.580Z","repository":{"id":33972471,"uuid":"162843586","full_name":"MrLuit/evm","owner":"MrLuit","description":"An ethereum virtual machine (EVM) bytecode decompiler","archived":false,"fork":false,"pushed_at":"2023-01-14T00:13:32.000Z","size":4091,"stargazers_count":172,"open_issues_count":31,"forks_count":44,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T00:05:10.244Z","etag":null,"topics":["bytecode","decompiler","ethereum","evm","solidity","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/evm","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrLuit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-22T21:23:08.000Z","updated_at":"2025-03-17T04:06:59.000Z","dependencies_parsed_at":"2023-01-15T03:46:05.635Z","dependency_job_id":null,"html_url":"https://github.com/MrLuit/evm","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrLuit%2Fevm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrLuit%2Fevm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrLuit%2Fevm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrLuit%2Fevm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrLuit","download_url":"https://codeload.github.com/MrLuit/evm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419859,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytecode","decompiler","ethereum","evm","solidity","typescript"],"created_at":"2024-11-10T03:25:15.673Z","updated_at":"2025-04-06T01:06:07.557Z","avatar_url":"https://github.com/MrLuit.png","language":"TypeScript","readme":"# EVM Bytecode Decompiler\n[![](https://img.shields.io/travis/com/MrLuit/evm.svg?style=flat-square)](https://travis-ci.com/MrLuit/evm)\n[![](https://img.shields.io/npm/v/evm.svg?style=flat-square)](https://www.npmjs.com/package/evm)\n[![](https://img.shields.io/david/MrLuit/evm.svg?style=flat-square)](https://david-dm.org/MrLuit/evm)\n[![](https://img.shields.io/github/license/MrLuit/evm.svg?style=flat-square)](https://github.com/MrLuit/evm/blob/master/LICENSE)\n    \nAn [Ethereum Virtual Machine (EVM)](https://medium.com/@jeff.ethereum/optimising-the-ethereum-virtual-machine-58457e61ca15) interpreter and decompiler, along with several other utils for programmatically extracting information from bytecode.\n\n## Usage\n\n\u003e npm i evm\n\n## Features\n- **Converting bytecode to opcodes**\n- **Reading information like events or functions from either bytecode or tx data**\n- **Extracting the [swarm hash](https://github.com/ethereum/wiki/wiki/Swarm-Hash) (if any) from bytecode**\n\n## API\n\n### Methods\n\n* **getBytecode()** - _Get raw bytecode (not really useful; same as input)_\n* **getOpcodes()** - _Returns opcodes including pc and pushData (if included)_\n* **getFunctions()** - _Parse functions from their signatures in bytecode_\n* **getEvents()** - _Parse events from their signatures in bytecode_\n* **getJumpDestinations()** - _Get array of program counters from JUMPDEST opcodes_\n* **getSwarmHash()** - _Get [Swarm hash](https://github.com/ethereum/wiki/wiki/Swarm-Hash) (if any) for [contract metadata](https://solidity.readthedocs.io/en/v0.5.2/metadata.html)_\n* **reset()** - _Reset the EVM state (stack, memory, etc.)_\n* **parse()** - _Interpret opcodes by looping over them, returns array of interpreted opcodes_\n* **decompile()** - _Decompile bytecode into readable [Solidity](https://en.wikipedia.org/wiki/Solidity)-like pseudocode_\n\n## Examples\n\n### Converting bytecode to opcodes\n\n#### Node.js\n\n```javascript\nconst { EVM } = require(\"evm\");\nconst Web3 = require('web3');\nconst web3 = new Web3(new Web3.providers.HttpProvider(\"https://api.mycryptoapi.com/eth\"));\n\nweb3.eth.getCode(\"0x06012c8cf97BEaD5deAe237070F9587f8E7A266d\").then(code =\u003e {  /* CryptoKitties contract */\n    const evm = new EVM(code);\n    console.log(evm.getOpcodes());  /* Get opcodes */\n});\n```\n\n#### Browser\n```javascript\nconst { EVM } = window.EVM_Utils;\nconst web3 = new Web3(window.web3.currentProvider);\nweb3.eth.getCode(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\", function(err,code) {  /* DAI contract */\n    if(err) throw err;\n    const evm = new EVM(code);\n    console.log(evm.getOpcodes());  /* Get opcodes */\n});\n```\n\n### Decompiling a contract\n\n#### Node.js\n\n```javascript\nconst { EVM } = require(\"evm\");\nconst Web3 = require('web3');\nconst web3 = new Web3(new Web3.providers.HttpProvider(\"https://api.mycryptoapi.com/eth\"));\n\nweb3.eth.getCode(\"0x06012c8cf97BEaD5deAe237070F9587f8E7A266d\").then(code =\u003e {  /* CryptoKitties contract */\n    const evm = new EVM(code);\n    console.log(evm.getFunctions());  /* Get functions */\n    console.log(evm.getEvents());  /* Get events */\n    console.log(evm.decompile());  /* Decompile bytecode */\n});\n```\n\n#### Browser\n```javascript\nconst { EVM } = window.EVM;\nconst web3 = new Web3(window.web3.currentProvider);\nweb3.eth.getCode(\"0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359\", function(err,code) {  /* DAI contract */\n    if(err) throw err;\n    const evm = new EVM(code);\n    console.log(evm.getFunctions());  /* Get functions */\n    console.log(evm.getEvents());  /* Get events */\n    console.log(evm.decompile());  /* Decompile bytecode */\n});\n```\n\n### Extracting data from transaction\n\n#### Node.js\n\n```javascript\nconst { Transaction } = require(\"evm\");\nconst Web3 = require('web3');\nconst web3 = new Web3(new Web3.providers.HttpProvider(\"https://api.mycryptoapi.com/eth\"));\n\nweb3.eth.getTransaction(\"0xd20a8d888a3f29471ea41ea77cc2d95ccd79ade1eaad059e83524e72b9adf962\").then(transactionData =\u003e {\n    const transaction = new Transaction();\n    transaction.setInput(transactionData.input);\n    console.log(transaction.getFunction());  /* Get function */\n});\n```\n\n#### Browser\n```javascript\nconst { Transaction } = window.EVM;\nconst web3 = new Web3(window.web3.currentProvider);\nweb3.eth.getTransaction(\"0xd20a8d888a3f29471ea41ea77cc2d95ccd79ade1eaad059e83524e72b9adf962\", function(err,transactionData) {\n    if(err) throw err;\n    const transaction = new Transaction();\n    transaction.setInput(transactionData.input);\n    console.log(transaction.getFunction());  /* Get function */\n});\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrluit%2Fevm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrluit%2Fevm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrluit%2Fevm/lists"}