Rise In Logo



Learn everything about Solidity

Solidity Basics and Remix IDE

In this lesson, you will be learning about Remix IDE. You can access Remix IDE here.

Down below, you will find the code that I will use in the video. Please copy the code, go to the Remix IDE, and follow along with me. If you encounter any problem, you can contact us through the discord channel.

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


contract Example {


    address owner;


    struct Counter {
        uint number;
        string description;
    }


    Counter counter;


    modifier onlyOwner() {
        require(msg.sender == owner, "Only the owner can increment or decrement the counter");
        _;
    }


    constructor(uint initial_value, string memory description) {
        owner = msg.sender;
        counter = Counter(initial_value, description);
    }


    function increment_counter() external onlyOwner {
        counter.number += 1;
    }


    function decrement_counter() external onlyOwner {
        counter.number -= 1;
    }


    function get_counter_value() external view returns(uint) {
        return counter.number;
    }
}

Comments

You need to enroll in the course to be able to comment!

Stay in the know

Never miss updates on new programs and opportunities.

Rise In Logo

Rise together in web3!

Disclaimer: The information /programs / events provided on https://patika.dev and https://risein.com are strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice and do not 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://patika.dev and https://risein.com disclaim any responsibility for financial decisions made by users based on information provided here.