Created
August 26, 2021 08:09
-
-
Save martinloesethjensen/72621b1cd218a37ace36265525a96bc6 to your computer and use it in GitHub Desktop.
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.0; | |
contract VolcanoCoin { | |
uint256 totalSupply = 10000; | |
address owner; | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
event TotalSupplyIncrease(uint); | |
event Transfer(uint, address); | |
constructor() { | |
owner = msg.sender; | |
balances[msg.sender] = totalSupply; | |
totalSupply = 0; | |
} | |
mapping(address => uint256) public balances; | |
mapping(address => Payment[]) public payments; | |
struct Payment { | |
uint256 transferAmount; | |
address recipient; | |
} | |
function getTotalSupply() public view returns (uint) { | |
return totalSupply; | |
} | |
function increaseTotalSupplyWith1000() public onlyOwner { | |
totalSupply += 1000; | |
emit TotalSupplyIncrease(totalSupply); | |
} | |
function transfer(uint256 amount, address recipient) public { | |
require(amount < balances[msg.sender]); | |
balances[msg.sender] -= amount; | |
balances[recipient] += amount; | |
payments[msg.sender].push(Payment(amount, recipient)); | |
emit Transfer(amount, recipient); | |
} | |
function getBalance() public view returns (uint) { | |
return balances[msg.sender]; | |
} | |
function getBalanceOf(address addr) public view returns (uint) { | |
return balances[addr]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment