0

Hi Ethereum Developer's,

Need your precious time..

I know this question is asked and solutions is given for the same

I have a smart contract---------

pragma solidity ^0.4.18;

contract myContract {

  struct UserInfo {
    uint uId;
    uint producerId;
    uint clientId;
    uint transId;
    uint weight;
    bytes32 addr;
    bytes32 suburb;
    bytes32 city;
    bytes32 country;
    bytes32 postcode;
    bytes32 lat;
    bytes32 lng;
    bytes32 titleType;
    bytes32 status;
    address advAddress; 
  }

  //Key-Value Pair between uId and UserInfo
  mapping (uint => UserInfo) userIdInfo;  

  //Function to store UserInfo on to the blockchain
  function landregister (uint uId, uint producerId, uint clientId, uint transId, uint weight, bytes32 addr, bytes32 suburb, bytes32 city, bytes32 country, bytes32 postcode, bytes32 lat, bytes32 lng, bytes32 titleType, bytes32 status) public returns(bool) 
  {
    var userinfo = userIdInfo[uId];

    userinfo.landId         = landId;
    userinfo.producerId     = producerId;
    userinfo.clientId       = clientId;
    userinfo.titleType      = titleType;
    userinfo.landSize       = landSize;
    userinfo.addr           = addr;
    userinfo.suburb         = suburb;
    userinfo.city           = city;
    userinfo.country        = country;
    userinfo.postcode       = postcode;
    userinfo.lat            = lat;
    userinfo.lng            = lng;
    userinfo.transId        = transId;
    userinfo.status         = status;
    userinfo.advAddress     = msg.sender;
    return true;
  }

  //Function to retrieve UserInfo from the blockchain
  function getUserById(uint index) public constant returns(uint, uint)
  { 
    return (userIdInfo[index].uId, userIdInfo[index].producerId);
  }
}

When i am trying to deploy it, it give me Error: Stack too deep, try removing local variables.

I have read many articles but not able to find solution ....

Please if anyone can help me with example for the same

Thanks in Advanced ......

0

1 Answer 1

1

The problem is that you are passing too many parameters to the constructor. Solidity supports up to 12 parameters being passed to a function.

You could try either separating the setup in 2 different functions or pass an array with the data to the constructor instead of multiple parameters.

Btw, the code you pasted doesn't compile as some parameters being passed did not match the struct data.

0

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