Created
November 15, 2021 05:05
-
-
Save marlomajor/00ef05b585b0fddec06d3329e13bda58 to your computer and use it in GitHub Desktop.
Encode Homework_4
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
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.7; | |
contract VolcanoCoin { | |
uint public totalSupply = 10000; | |
address owner; | |
mapping(address => uint) public balances; | |
error Unauthorized(); | |
constructor() { | |
owner=msg.sender; | |
balances[owner] = totalSupply; | |
} | |
modifier onlyOwner { | |
if (msg.sender==owner) { | |
_; | |
} | |
} | |
struct Payments { | |
uint transferAmount; | |
address recipientAddr; | |
} | |
mapping (address => Payments) transactions; | |
event TransferComplete(uint, address); | |
function transfer(uint _amount, address _recipientAddr) public { | |
if (msg.sender != owner) { | |
revert Unauthorized(); | |
} | |
payable(_recipientAddr).transfer(_amount); | |
emit TransferComplete(_amount, _recipientAddr); | |
} | |
function getTotalSupply() public view returns(uint) { | |
return totalSupply; | |
} | |
event TotalSupplyUpdated(uint); | |
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