Shaminda
Shaminda

Reputation: 343

error in smart contract indicate haven't unique attribute.

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

Upvotes: 1

Views: 38

Answers (1)

user94559
user94559

Reputation: 60153

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.

Upvotes: 1

Related Questions