I am working on a project and I was wondering if its possible to retrieve the bytecode of another smart contract on Ethereum though my smart contract ?

So basically, I will have a copy of that smart contract, then I can process it in an off-chain solution.

Is this possible ?

  • You don't need a smart contract to grab the bytecode of a contract to process it off chain, you can directly grab it with eth_getCode. You probably want to save the cost of deploying the contract and go that way
    – Foxxxey
    Sep 2 at 23:03

1 Answer 1


In solidity:

contract Foo {
  function foo(address bar) public view returns (bytes memory) {
    return bar.code;

The opcode is EXTCODECOPY

Your Answer

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

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