let us suppose my contract looks like:

contract Site_contract{

    struct details{

        bytes32[] name;
        bytes32[] location;
        uint256 number;

    site_details private this_site;   

    function Site_contract(struct this_site_){

        this_site = this_site_;


And i am getting error, doing soo. Can someone tell me where did i go wrong?

  • What error were you getting?
    – Daniel Que
    Feb 1, 2018 at 23:18

2 Answers 2


site_details private this_site should be details private this_sitefor starters


First of all you are declaring the struct reference wrong as pointed out by Sven Deckers.

Secondly, no, you cannot pass struct to a constructor as it will be receiving its input outside from the blockchain. Only the private and internal functions can expect structs as input parameters.

However, the work around here is to receive each individual primitive data type inside struct as individual parameters to the constructor like

details private this_site;

function Site_contract(bytes32 _name, bytes32 _location, uint256 _number){

    this_site = details(_name, _location, _number);


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.