1

I would like to extract the runtime bin from the EVM bin that can be found in the etherscan.io.

For instance for this famous contract (https://etherscan.io/address/0xecb4380189e22ed2abccff53a6ac1d1e02bd6981), when I use the online decompiler (https://ethervm.io/decompile?address=0xecb4380189e22ed2abccff53a6ac1d1e02bd6981&network=) to decompile, clearly it starts from a bytecode sequence 606060405236156100f8, which is not the very beginning of this EVM bytecode sequence.

I understood that I can do a pattern match to figure out a sequence of 606060405236, but I am a bit worried whether that's too "ad-hoc", and unable to handle all the cases. So could anyone shed some lights on a more principled approach here? Thank you.

2

To obtain the bytecode of a contract you have to call web3.eth.getCode.

An example from the linked page

var code = web3.eth.getCode("0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8");
console.log(code); // "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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