Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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