This question has been asked before in all sorts of convoluted ways. I am asking a very simple question and would like a very straight forward answer (if possible). What does the result of the call to web3.eth.getCode(<contract-address>) return:

  • type(Contract).creationCode
  • type(Contract).runtimeCode

Assuming of course the contract-address is the address of Contract


No, the getCode method gives back the runtime code which is stored on the Blockchain.

you can see that in this article:

Runtime Bytecode:

This is the code that is stored on-chain that describes a smart contract. This code does not include the constructor logic or constructor parameters of a contract, as they are not relevant to the code that was used to actually create the contract. The runtime bytecode for a contract can be retrieved on-chain by using an assembly block and calling extcodecopy(a). The hash of the runtime bytecode is returned from extcodehash(a). This opcode was introduced with EIP 1052 and included in the Constantinople hard fork.

This code can be retrieved on-chain usingtype(ContractName).runtimeCode. Finally, this code can be retrieved off-chain by the JSON RPC call, getCode.

  • Literally amazing, thank you that article is exactly what I needed! – foba May 21 at 18:16

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.