Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created February 24, 2022 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/0288018fe3f8dae91ccb281f50d4dc5d to your computer and use it in GitHub Desktop.
Save BetterProgramming/0288018fe3f8dae91ccb281f50d4dc5d to your computer and use it in GitHub Desktop.
// 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