Skip to content

Instantly share code, notes, and snippets.

@martinloesethjensen
Created August 26, 2021 08:09
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 martinloesethjensen/72621b1cd218a37ace36265525a96bc6 to your computer and use it in GitHub Desktop.
Save martinloesethjensen/72621b1cd218a37ace36265525a96bc6 to your computer and use it in GitHub Desktop.
// 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