Last active
October 22, 2021 11:58
-
-
Save tegila/4cde4669c059a3f1729b7f194bbc62a8 to your computer and use it in GitHub Desktop.
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
// contracts/Valoriza.sol | |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; | |
contract Valoriza is ERC20, AccessControl { | |
using SafeMath for uint256; | |
// Create a new role identifier for the minter role | |
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); | |
uint256 public factore; | |
constructor () ERC20("Valoriza Coin", "VALORIZA") { | |
// Grant the minter role to a specified account | |
factore = 100; | |
_setupRole(MINTER_ROLE, msg.sender); | |
_mint(msg.sender, 10000 * (10 ** uint256(decimals()))); | |
} | |
function mint(address to, uint256 amount) public { | |
// Check that the calling account has the minter role | |
require(hasRole(MINTER_ROLE, msg.sender), "Caller is not a minter"); | |
_mint(to, amount); | |
} | |
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { | |
return super.transfer(recipient, amount.div(factore)); | |
} | |
function totalSupply() public view virtual override returns (uint256) { | |
return factore.mul(super.totalSupply()); | |
} | |
function balanceOf(address account) public view virtual override returns (uint256) { | |
return factore.mul(super.balanceOf(account)); | |
} | |
function setFactore(uint256 _factore) public | |
{ | |
require(hasRole(MINTER_ROLE, msg.sender), "Caller is not a minter"); | |
factore = _factore; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment