0

I am creating a simple contract but i am getting the error, i tried few solutions but none of the them worked fine

Code:

pragma solidity >=0.7.0 <0.9.0;

contract Ballot {
   
    struct Voter {
        string title;
        string description;  
        string organization; 
        string ballotType;
        uint voteRights;
        uint noOfVoters;
        string option1;
        string option2;
        string option3;
        string option4;   
    }

    mapping(uint=>Voter) public voting;

    function addItems(string memory _title,string memory _description,string memory _organization,string memory _ballotType,uint _voteRights,uint _noOfVoters,string memory _option1,string memory _option2,string memory _option3,string memory _option4) public
    {
       voting.title=_title;
       voting.description=_description;
       voting.organization=_organization;
       voting.ballotType=_ballotType;
       voting.voteRights=_voteRights;
       voting.noOfVoters=_noOfVoters;
       voting.option1=_option1;
       voting.option2=_option2;
       voting.option3=_option3;
       voting.option4=_option4;
    }

}
1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Mar 22, 2022 at 18:23

1 Answer 1

1

You need a key value for your mapping to update itself. For example:

voting[0].title = _title;
voting[0].decryption = _descryption;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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