Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Truffle deployed contracts can't be verified through Etherscan #456

Description

@akravin

Issue

Truffle deployed contracts can't be verified through Etherscan (https://etherscan.io/verifyContract)

Steps to Reproduce

  1. Init a new Truffle project:
$ mkdir test-contract
$ cd test-contract
$ truffle init
  1. 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;
        }
    }
}
  1. Compile the Truffle project:
$ cd test_contract
$ truffle compile
  1. See the bytecode generated by Truffle compiler in test-contract/build/Ownable.json file in "unlinked-bytecode" attribute.

  2. (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

  • Operating System:
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 version:
Truffle v3.2.4
  • Solidity compiler
0.4.11+commit.68ef5810.Emscripten.clang
  • Ethereum client:
geth 1.6.1-stable-021c3c28
  • node version:
nodejs v6.3.1
  • npm version:
npm 4.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions