Created
February 24, 2022 18:00
-
-
Save BetterProgramming/0288018fe3f8dae91ccb281f50d4dc5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contracts/Box.sol | |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract Box is Ownable { | |
uint256 private value; | |
// Emitted when the stored value changes | |
event ValueChanged(uint256 newValue); | |
// Stores a new value in the contract | |
function store(uint256 newValue) public onlyOwner { | |
value = newValue; | |
emit ValueChanged(newValue); | |
} | |
// Reads the last stored value | |
function retrieve() public view returns (uint256) { | |
return value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment