I have a solidity contract which compiled fine in remix and when I try to deploy it I cannot pass parameters to the constructor method from the create button. It seems disabled. But once after I click create I am able to pass constructor parameters from the constructor method button. Using solidity compiler 0.4.18.

Is that normal behavior? The code is below

pragma solidity ^0.4.0;  
contract Election{  

    struct Candidate{  
        string name;  
        uint voteCount;  

    struct Voter{  
        bool voted;  
        uint voteIndex; //this is the candidate index whom the voter cast vote  
        uint weight; // this is to make sure the voter is authorized and has a   specific value other than default   
    address public owner;  
    string public name;  
    mapping (address => Voter) public voters;  
    Candidate [] public candidates;  
    uint public electionEnd;  
    event ElectionResult(string name, uint voteCount);  

    function election(string _name, uint durationMinutes, string candidate1, string candidate2 ){
        owner = msg.sender;
        name = _name;
        electionEnd = now + (durationMinutes * 1);

    function authorize(address voter){

        require(msg.sender == owner);
        //voters[voter] = Voter(false,0); This will allow any address to vote
        voters[voter].weight = 1;
    function vote(uint voteIndex){
        require(now < electionEnd);
        voters[msg.sender].voted = true;
        voters[msg.sender].voteIndex = voteIndex;
        candidates[voteIndex].voteCount += voters[msg.sender].weight;
    function end(){
        require(msg.sender == owner); 
        require(now >= electionEnd);
        for(uint i=0; i< candidates.length; i++){ // the for loop will publish election results for each candidate
            ElectionResult(candidates[i].name, candidates[i].voteCount); // calling the event to display result in UI passing results
  • Does the constructor function have the exact same name as the contract? If not, therein lies the problem as remix accepts constructor inputs based on the function having the same name as the contract. Otherwise, my only thought is it might be useful to share the code in question if possible.
    – ryanh
    Commented Jan 17, 2018 at 1:00
  • yes the constructor function has the same name as the contract except contract has a upper case to begin with. I will share the code.
    – sijo0703
    Commented Jan 19, 2018 at 1:45

2 Answers 2


The constructor function name is 'election' but your contract is called 'Election' you need to capitalise the E on the constructor which would make it function Election(string _name, uint durationMinutes, string candidate1, string candidate2 )


As @willjgriff said, the constructor function need to have same name than the contract one. Fixing the maj. E will do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.