2

I'm trying to verify my deployed contract on etherscan.io

However I get the following error:

"rror! Unable to generate Contract ByteCode and ABI"

I'm not putting in an ABI because my constructor doesn't have any values or arguments.

What am I doing wrong?

Below is my contract code:


pragma solidity ^0.4.0;

// deploying contract on account 0x80A3bA6F52D63aFF73cA582343C2F67046DcEC6f
contract PayCheck {
    //List all the empolyees ethereum payment addresses in an array.
    address[] employees = [0x9391ea51c338410B6603e38dD14C00a1b218C8d5, 0x9391ea51c338410B6603e38dD14C00a1b218C8d5 ];

    //Set a variable that trackes the total recieved to the contract, starting with 0.
    uint totalReceived = 0;

    //Create a dictionary that tracks how much as been withdrawn to each ethereum address.
    mapping (address => uint) withdrawnAmounts;

    //This function updates the total amount that's been sent to the contract 
    function PayCheck() payable {
        updateTotal();
    }
    function () payable {
        updateTotal();
    }
    // This is an internal function that updates the total amount that's been sent to the contract.
    function updateTotal() internal {
        totalReceived += msg.value;
    }

    //Here is a modifier that ensures only people in the empolyees list that execute the withdraw function.
    modifier canWidthdraw() {
        bool contains = false;

    //A simple for loop that check if they are in the empolyee list before it's aloud to execute the function this modifier is assigned to.    
        for(uint i = 0; i < employees.length; i++) {
            if(employees[i] == msg.sender) {
                contains = true;
            }
        }
        require(contains);
        _;
    }

    // Function that calculates what the user can withdraw and to where.
    function withdraw() canWidthdraw {
        uint amountAllocated = totalReceived/employees.length;
        uint amountWithdrawn = withdrawnAmounts[msg.sender];
        uint amount = amountAllocated - amountWithdrawn;
        withdrawnAmounts[msg.sender] = amountWithdrawn + amount;
        if (amount > 0) {
            msg.sender.transfer(amount);
        }
    }

}

enter image description here

1

You need to select the compiler and set optimization to match the method you used to compile the bytecode that is actually deployed. Here, ^ confuses matters because it could be anything 0.4 or higher.

You can test your actual compiler, but the method to do so will depend on what you used. For example, solc version or truffle version. Etherscan is going to compile the pasted source as instructed and compare to the bytecode it actually finds on the chain at the address you specified. When there's a match, it will record it and indicate the source you pasted is legit.

Hope it helps.

  • Yay I did it, Thanks Rob, I was using solidity remix, and the way I checked the details of the compiler, and worked out I deployed it using version: 0.4.19+commit.c4cbbb05 I simply changed it to the correct compiler and it worked. Thanks Rob and Merry Xmas! – Thomas Miller Dec 26 '17 at 10:03

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.