I know this question has been asked many times before. I've read loads of answers, but nothing seems to work for me. I first tried to verify the source code of a much larger, more complex contract, but it didn't work, so I wrote a very simple tiny contract in Solidity:
pragma solidity ^0.4.17;
contract SimpleTest
{
string public blablabla;
function SimpleTest() public
{
blablabla = "Hello world!";
}
}
As you can see, I'm not using any constructor arguments, import statements or libraries. I compiled and deployed it using Solidity 0.4.17 from inside Parity. Optimization was enabled. I did not use one of the nightly builds.
Contract creation transaction:
https://etherscan.io/tx/0x2d8615c8bfc548a210781443c872737d890f6c4a5aa373c3d6d20bbaac941b8d
The contract in question:
https://etherscan.io/address/0x5a8b57a6cf17a196e000eca4481257d5d3025636
Link to the verification page:
https://etherscan.io/verifyContract?a=0x5a8b57a6cf17a196e000eca4481257d5d3025636
The error message I get from etherscan.io is:
Sorry! The Compiled Contract ByteCode for 'SimpleTest' does NOT match
the Contract Creation Code for
[0x5a8b57a6cf17a196e000eca4481257d5d3025636]Contract name(s) found: 'SimpleTest'
Unable to Verify Contract at this point time.
I've analyzed the bytecodes a little bit, and I found that:
-
The input data of the contract creation transaction is exactly equal to the bytecode I got from Parity.
-
The bytecode that the etherscan.io verifier produces is similar to the bytecode from Parity, and thus also similar to the input data of the contract creation transaction.
-
The bytecode on the contract page on etherscan.io is much shorter than the other bytecodes.
-
All the bytecodes contain 2 large strings of 00 bytes, except the bytecode on the etherscan.io contract page, it only contains 1 large string of 00 bytes.
I really have no idea what's going on here. Can anyone help?
Best Answer
I was able to verify my contract with optimization turned on, when compiling from remix:
https://ethereum.github.io/browser-solidity/
For some reason, it produces a different bytecode from Parity, even if you select the same compiler version and the same optimization setting.