Possible outputs of the Solidity compiler include creation bytecode and deployed (runtime) bytecode. However, this compiled deployed bytecode might not be the same as the one that will actually be deployed on the blockchain. This might be the case if the contract requires constructor arguments to initialize immutable variables. So, how do I use the mentioned artifacts (creation bytecode, deployed bytecode, constructor arguments) and generate the actual deployed bytecode, without actually deploying it. One possible option is to deploy to a (local) testnet and then see the deployed bytecode, but this seems like an overkill.

Ok, to make things clearer, this is the nomenclature (I didn't make it up: What is the difference between bytecode, init code, deployed bytedcode, creation bytecode, and runtime bytecode?):

deployed bytecode = runtime bytecode

actual deployed bytecode = actual runtime bytecode

This question concerns the fact that it is sometimes the case that:

deployed bytecode (as predicted by compilation) =/= actual deployed bytecode (after deployment)

In fact, the last formula generally holds when a contract uses immutable variables.

1 Answer 1


This GitHub issue helped me find the answer. Basically what I needed can be achieved with the ethereumjs-vm module:

const VM = require("ethereumjs-vm").default;
const BN = require("bn.js");
const vm = new VM();

    code: Buffer.from(creationBytecode + abiEncodedConstructorArguments, "hex"),
    gasLimit: new BN(...),
}).then(results => {
    const actualDeployedBytecode = results.returnValue.toString("hex");

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.