Last active
November 11, 2021 06:27
-
-
Save marlomajor/d89087107dfd857f146e226001594148 to your computer and use it in GitHub Desktop.
Homework_3
This file contains hidden or 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
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.7; // Homework said ^0.8.0, but he also said choose latest available to us, so going with ^0.8.7 | |
contract VolcanoCoin { | |
// initialize owner in constructor | |
constructor() { owner=msg.sender; } | |
// set variables for totalSupply and ownerAddress | |
uint totalSupply = 10000; | |
address owner; | |
// create modifier to be used to scope visibility when changing contract | |
modifier onlyOwner { | |
if (msg.sender==owner) { | |
_; | |
} | |
} | |
// simple getter to return total supply (can also do this inline with `public` keyword on variable instantiation | |
function getTotalSupply() public view returns(uint) { return totalSupply; } | |
// broadcast supply change to network | |
event TotalSupplyUpdated(uint); | |
// owner permissable function to allow the increase in supply | |
function increaseSupply(uint _totalSupply) public onlyOwner { | |
_totalSupply = _totalSupply + 1000; | |
emit TotalSupplyUpdated(_totalSupply); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment