Long story short I lost the contract code that I deployed. This is deployed to the live net. Is there anyway of being able to view the source of the contract code that has been deployed?


2 Answers 2


If you know the address of the contract on the live net you can get its bytecode and decompile with this tool https://github.com/comaeio/porosity Here is an example from their README:

> porosity --abi $abi --code $code --decompile --verbose 0

Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.

Attempting to parse ABI definition...

Hash: 0x5FD8C710
function withdrawBalance() {
      if (msg.sender.call.gas(4369).value(store[msg.sender])()) {
         store[msg.sender] = 0x0;

L3 (D8193): Potential reetrant vulnerability found.

LOC: 5
Hash: 0xC0E317FB
function addToBalance() {
      store[msg.sender] = store[msg.sender] + msg.value;

LOC: 4
Hash: 0xF8B2CB4F
function getBalance(address) {
      return store[arg_4];

LOC: 3

Check out tools like JEB Decompiler or Ethervm.io.

JEB is interactive decompiler that produces very readable code, some of which can be modified (e.g. variable and function names).

Ethervm is a free web portal. The output is not as clean but it is quite convenient to use for one-off decompilations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.