Rise In Logo

Solidity Fundamentals

In the last lesson, we have created our Proposal structure and we also defined a mapping for this structure. We also said that we need a system so that we can keep track of the ids.

In this lesson, we will be creating a Counter so that we can keep track of the ids.

You can define the counter as:

uint256 private counter;

After adding the counter, your contract should look like this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;


contract ProposalContract {
    uint256 private counter; // This line is added
    struct Proposal {
        string description; // Description of the proposal
        uint256 approve; // Number of approve votes
        uint256 reject; // Number of reject votes
        uint256 pass; // Number of pass votes
        uint256 total_vote_to_end; // When the total votes in the proposal reaches this limit, proposal ends
        bool current_state; // This shows the current state of the proposal, meaning whether if passes of fails
        bool is_active; // This shows if others can vote to our contract
    }


    mapping(uint256 => Proposal) proposal_history; // Recordings of previous proposals
}
Rise In Logo

Rise together in web3

Website

BootcampsWhat is the
Web3 Bootcamp?
CommunityPartner with UsBlogEvents

Bootcamps

Company

About UsJoin UsFAQTerms ConditionsPrivacy PolicyGDPR NoticeCookies