0
pragma solidity ^0.4.0;
contract contracta{
    uint mapsize=10;
    struct request_task{ 
    uint task_id; 
    string ip_address;
    uint flag ;// submited, 1, excuteding, 2, finished, 3, failed
    uint task_submit_time; // 08:12:01 06/18/2018
    uint task_deadline; //  09:12:01 06/18/2018
    uint  provided_price; // maximum price: $10 per hour
    uint bandwidth; // minimum: 100.00 KBP
    }
    request_task[] private request;
    uint internal countera;
    function contracta() internal{
        add(1,"172.168.3.3",1,10,30,5,200);
        add(1,"172.168.3.3",1,10,30,5,200);

    }
    function add(uint _task_id,string _ip_address,uint _flag,uint _task_submit_time,uint _task_deadline,uint  _provided_price,uint _bandwidth) internal{
        request.push(request_task(_task_id,_ip_address,_flag, _task_submit_time,_task_deadline,_provided_price,_bandwidth));
    }
    function get()constant returns(uint){
        return request[1].task_submit_time;
    }

}
2

You can't deploy a contract with an internal constructor. Use public instead:

function contracta() public {
    add(1,"172.168.3.3",1,10,30,5,200);
    add(1,"172.168.3.3",1,10,30,5,200);
}

BTW, you're using an extremely old version of the Solidity compiler. The current version is 0.4.23. There's an improved constructor syntax these days:

constructor() public {
    ...
}
  • A constructor can be internal, you just won't be able to deploy (or create) the contract. The point of a constructor being internal is if you want to explicitly state that you do not want to deploy (or create) the contract, yet you still want to inherit from it (i.e., extend it into a deployable contract). – goodvibration May 6 '18 at 7:11

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.