error in smart contract indicate haven't unique attribute.

43 views Asked by At

I tried to write a smart contract which is able to complaining. Here is the code

pragma solidity ^0.4.2;

contract Complain {
    //Model Complain
    struct compalins {
        uint id;
        string category;
        string desc;
        string complainer;
    }

    mapping( uint => complains) public newComplain;

    uint public complainCount;

    function Complain () public {
        addComplain("c1","bhbh","bybhb");
        addComplain("c2","bhbh","bybhb");
    }

    function addComplain (string _category,string desc,string complainer){
        complainCount ++;
       // newComplain[ComplainCount] = complains(complainCount,_category,desc,complainer);
    }
}

in this mapping function gives an error and say structure of the complains haven't Unique value. But id is Unique.

Please help me to solve this issue

1

There are 1 answers

0
user94559 On BEST ANSWER

You misspelled "complains" when you declared your struct. (You spelled it "compalins" there.) So the error on the mapping line is that there's no such identifier "complains". If you fix the typo, the code will compile.