

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Assignment i have Implemented on Blockchain
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyContract { address public owner; bool public paused; uint256 public criticalData; modifier onlyOwner() { require(msg.sender == owner, "Only contract owner can call this function."); _; } modifier whenNotPaused() { require(!paused, "Contract is paused."); _; } constructor() { owner = msg.sender; paused = false; } function pauseContract() public onlyOwner { paused = true; } function unpauseContract() public onlyOwner { paused = false; } function criticalFunction(uint256 newValue) public whenNotPaused onlyOwner { criticalData = newValue; } }
Output :