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!