0

Here is my code

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract GeoSpatialData{

    uint public SpatialDataCount = 0;
    
    struct GeoData{
        uint id;
        address owner_address;
        string data_name;
        string data_year;
        string data_description;
        string data_img_url;
        string data_url;
        string data_category;
        string data_published_date;
    }

    GeoData[] public geoDatas;

    mapping (uint => GeoData) public geodatas;
    // write function
    function createData(string memory _data_name,address _owner_address,string memory _data_year,string memory  _data_description,string memory _data_image_url,string memory _data_url,string memory _data_published_date,string memory _data_category,uint _id ) public{
        SpatialDataCount++;
        uint used_id = SpatialDataCount+_id;
        geoDatas.push(GeoData({id: used_id,owner_address:_owner_address,data_name:_data_name,data_year:_data_year,data_description:_data_description,data_img_url:_data_image_url,data_url:_data_url,data_category:_data_category,data_published_date:_data_published_date}));
        // geoDatas.push(Ge)
    }
    // read all data  function
    // function fetchAlldata() public view returns(GeoData[] memory){
    //     GeoData[] memory geodatas
    //         return GeoData;
    // }

    // read single data function 
    // function readSingle() public{

    // }

}

I have research on the google etherium stackexchange the answers which i am getting is not understandable but i understand the issue that i can only use 7 variables but i need to store these all variables its my requirement is there really no way like i have readed on the forums i am using matic which is much cheaper than etherium so cost will not be an issue for storing data

4
  • Can you explain better about error you are receiving? Commented Mar 14, 2022 at 13:24
  • It says i cant use more than 7 variables in my struct
    – sarangkkl
    Commented Mar 14, 2022 at 14:19
  • 1
    @sarangkkl IIRC its 16 vars limit, not 7, maybe try newer versions of solidity
    – Meet
    Commented Mar 14, 2022 at 15:26
  • @sarangkkl It compiles without issue with solc 0.8.7.
    – Ismael
    Commented Mar 17, 2022 at 4:25

1 Answer 1

1

Why don't you write it like this?

function createData(GeoData memory _data) {
  // do something to _data
}
2
  • I dont know can you please correct
    – sarangkkl
    Commented Mar 14, 2022 at 13:09
  • That is my correction Commented Mar 14, 2022 at 13:10

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