I'm trying to reproduce the following contract compilation on Etherscan: https://etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d#code.
Runtime bytecode on-chain
I can get the runtime bytecode on chain by calling eth_getCode
for the contract address from a JSON RPC client connected to mainnet.
Here is the bytecode I get:
60806040526004361061018f5760003560e01c80638803dbee116100d6578063c45a01551161007f578063e8e3370011610059578063e8e3370014610c71578063f305d71914610cfe578063fb3bdb4114...
Runtime bytecode (Etherscan)
Here, looking at the etherscan contract information in the link above, I notice 3 key things: compiler version (0.6.6
), optimisation runs (999999) and evm version (istanbul).
So I set up Solidity compilation as follows:
{
"language": "Solidity",
"sources":
{
"uniswap.sol":
{
"urls":
[
"./uniswap.sol"
]
}
},
"settings": {
"optimizer": {
"runs": 999999
},
"evmVersion": "istanbul",
"outputSelection": {
"*": {
"*": [ "evm.deployedBytecode" ]
}
}
}
}
and ran with:
solc --standard-json --allow-paths .
But I'm getting slightly different bytecode:
60806040526004361061018f5760003560e01c80638803dbee116100d6578063c45a01551161007f578063e8e3370011610059578063e8e337001461131e578063f305d71914611406578063fb3bdb4114...
What could be wrong in the reproduction and how may I amend it? Can constructor arguments change runtime bytecode if immutable values are used?
"enabled": true
? – Ismael Oct 5 '20 at 22:24