Created
December 2, 2021 15:53
-
-
Save marlomajor/9f04b6b252ecd9fce85202bfc320920f to your computer and use it in GitHub Desktop.
VolcanoCoin.sol
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.0; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/utils/Strings.sol"; | |
contract VolcanoCoin is ERC20("Volcano Coin", "VOL"), Ownable{ | |
constructor() { | |
_mint(msg.sender, initialSupply); | |
} | |
uint256 constant initialSupply = 10000; | |
struct Payment{ | |
uint amount; | |
address recipient; | |
} | |
mapping (address => Payment[]) public payments; | |
event supplyChanged(uint256); | |
function transfer(address _recipient, uint _amount) public virtual override returns (bool) { | |
_transfer(msg.sender, _recipient, _amount); | |
addPaymentRecord(msg.sender, _recipient, _amount); | |
return true; | |
} | |
function addPaymentRecord(address _sender, address _recipient, uint _amount) internal { | |
payments[_sender].push(Payment(_amount,_recipient )); | |
} | |
function addToTotalSupply(uint256 _quantity) public onlyOwner { | |
_mint(msg.sender,_quantity); | |
emit supplyChanged(_quantity); | |
} | |
function getPayments(address _user) public view returns (Payment[] memory) { | |
return payments[_user]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment