• Discover
  • Partner with us
  • Chapters
  • Blog

Learn everything about Solidity

Getting Started
✨Connect Your Profile to Open Campus
Introduction to Remix IDE
Counter Contract and Solidity Basics
Submit Your First Homework
Solidity Cheat Sheet
Creating Proposal Structure
Submit Your Second Homework

Creating a Counter
Creating a Proposal
Submit Your Third Homework
The Constructor
OnlyOwner Modifier
Voting Functionality

Correcting the Voting Functionality
Correcting the Voting Functionality 2
Calculating the Current State of a Proposal
Submit Your Fourth Task
Finalizing Proposal Contract
Final Version of the Proposal Contract

Submit Your Final Homework
Next Steps

Last lesson, we said that we had 2 problems in our logic.

  • The first problem is that a user can vote for a proposal even it is not active.
  • The second problem is that, a user can vote to the same proposal over and over again.

You will be solving this issues with the help of the modifiers.

The first modifier you are going to be creating will check whether the current proposal is active or not.

modifier active() {
    require(proposal_history[counter].is_active == true, "The proposal is not active");
    _;
}

The modifier checks whether the proposal is active or not. If the proposal is not active, it returns the message "The proposal is not active".

This modifier will check if the voter has voted before. But to check this you need a keep the addresses that has voted for our contract. We can achieve this with an array.

Let's create the following variable under the mapping.

address[]  private voted_addresses;

Next, you need to modify our constructor so that we can add the owner of the contract to the array since the owner of the contract will be the one who creates the proposals and we do not want him/her to vote on the contracts that himself/herself has created.

You will be adding the following line at the end of our contructor function:

voted_addresses.push(msg.sender);

Now, your constructor becomes:

constructor() {
    owner = msg.sender;
    voted_addresses.push(msg.sender);
}
Previous
Next

Lesson discussion

Swap insights and ask questions about “Learn everything about Solidity”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
WebsiteDiscoverPartner with UsBlogEvents
Discover
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsBrand GuidelineFAQsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://risein.com is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://risein.com disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Rise In, All rights reserved