Let’s say that I created a contract and, using that, I and other people, made many transactions which meaning is undoubtably proven reading the contract.

At a certain point someone kills the contract and all the code is canceled.

How can I prove the meaning of the transactions made in the past if the code has been deleted? Is there any practical method to going back to old blocks in order to extract the smart contract which have been used at the time?

  • 1
    I've not used contract kill, but does it remove the eth.getCode(contractAddress) value? Even if so,eth.getCode also takes a blockNumber parameter which will at least get you the run-time bytecode of the contract.
    – sp4c3
    Feb 1, 2019 at 7:42

2 Answers 2


The method to extract the code eth.getcode takes an optional block height parameter as documented here. The function signature is:

web3.eth.getCode(addressHexString [, defaultBlock] [, callback]),

where defaultBlock (Maybe "block" would have been a better name?) can be any block number or some special valued strings such as "earliest", "latest", or "pending". You can see the documentation here.

This means that you will be able to extract the code of the contract N blocks back. But you should note that you need to run a blockchain node which stores and indexes all historic information in order for you to be allowed to make the call at an arbitrary block height. In Parity wallet, this setting is referred to as --pruning archive, cf. https://wiki.parity.io/Getting-Synced#database-pruning.

You should also note that this function call will return the binary code of the contract, not the source code. If you receive the source code through some other souce, you can however, verify that the binary code returned by getcode matches the source code by compiling the source code with the option --bin-runtime as described in this answer:

Nothing that takes place on the blockchain is ever deleted :)

  • A note about 'nothing ... is ever deleted': logs may get deleted at some point in the future: ethereum.stackexchange.com/q/66336/31933 Feb 1, 2019 at 9:28
  • @LauriPeltonen the past blocks will likely always be available though, so you'll still be able to calculate the logs given the history
    – natewelch_
    Feb 3, 2019 at 22:28

You may try to access historic ETH data accumulated by explorers (e.g. ORS CryptoHound)

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.