Issue
Truffle deployed contracts can't be verified through Etherscan (https://etherscan.io/verifyContract)
Steps to Reproduce
- Init a new Truffle project:
$ mkdir test-contract
$ cd test-contract
$ truffle init
- Create a simple Ownable contract (Ownable.sol) in "test-contract/contracts" folder:
pragma solidity ^0.4.11;
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
- Compile the Truffle project:
$ cd test_contract
$ truffle compile
-
See the bytecode generated by Truffle compiler in test-contract/build/Ownable.json file in "unlinked-bytecode" attribute.
-
(Optional). Deploy Ownable contract to Ethereum (TEST-NET)
$ cd test-contract
$ truffle migrate
-- Deploy only ownable and standard token
Running migration: 1_initial_migration.js
Deploying Migrations...
Migrations: 0x822432d53f6a8e5f2d4dad208fe1eecd33cf053d
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying Ownable...
Ownable: 0x6c8e1b321ce94b12069222b543558d4159527ecd
Saving successful migration to network...
Expected Behavior
The bytecode generated by Truffle must be the same as bytecode generated by Remix (online compiler) or solcjs (local compiler), i.e.:
6060604052341561000c57fe5b5b60008054600160a060020a03191633600160a060020a03161790555b5b610119806100396000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416638da5cb5b81146043578063f2fde38b14606c575bfe5b3415604a57fe5b60506087565b60408051600160a060020a039092168252519081900360200190f35b3415607357fe5b6085600160a060020a03600435166096565b005b600054600160a060020a031681565b60005433600160a060020a0390811691161460b15760006000fd5b600160a060020a0381161560e8576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b5b505600a165627a7a723058201eb1de901e30ec9818544272a4c70946cd9cb7cd848237ba3dca118e44d771a60029
Actual Results
The actual bytecode generated by Truffle compiler is different from the bytecodes generated by Remix (online compiler) or solcjs (local compiler):
0x6060604052341561000c57fe5b5b60008054600160a060020a03191633600160a060020a03161790555b5b60f3806100386000396000f300606060405263ffffffff60e060020a6000350416638da5cb5b8114602a578063f2fde38b146053575bfe5b3415603157fe5b6037606e565b60408051600160a060020a039092168252519081900360200190f35b3415605a57fe5b606c600160a060020a0360043516607d565b005b600054600160a060020a031681565b60005433600160a060020a0390811691161460985760006000fd5b600160a060020a0381161560c25760008054600160a060020a031916600160a060020a0383161790555b5b5b505600a165627a7a72305820607fc60d96cffbd50e58fbc028c1e4b6f3dfdf356bd439390481a479ef8d25500029
See https://ropsten.etherscan.io/address/0x6c8e1b321ce94b12069222b543558d4159527ecd
RESULT: The SolJS bytecode is identical to the Remix bytecode but different from the truffle bytecode.
Environment
OS: Ubuntu 15.10
uname -a
Linux sasha 4.2.0-42-generic #49-Ubuntu SMP Tue Jun 28 21:26:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Truffle v3.2.4
0.4.11+commit.68ef5810.Emscripten.clang
geth 1.6.1-stable-021c3c28
nodejs v6.3.1
npm 4.6.1
Issue
Truffle deployed contracts can't be verified through Etherscan (https://etherscan.io/verifyContract)
Steps to Reproduce
pragma solidity ^0.4.11; contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner { if (msg.sender != owner) throw; _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } }See the bytecode generated by Truffle compiler in test-contract/build/Ownable.json file in "unlinked-bytecode" attribute.
(Optional). Deploy Ownable contract to Ethereum (TEST-NET)
Expected Behavior
The bytecode generated by Truffle must be the same as bytecode generated by Remix (online compiler) or solcjs (local compiler), i.e.:
Actual Results
The actual bytecode generated by Truffle compiler is different from the bytecodes generated by Remix (online compiler) or solcjs (local compiler):
See https://ropsten.etherscan.io/address/0x6c8e1b321ce94b12069222b543558d4159527ecd
RESULT: The SolJS bytecode is identical to the Remix bytecode but different from the truffle bytecode.
Environment