wuniContract.sol
Specialized reward token for ecosystem-wide distribution mechanisms.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/// @title WUNIToken - An ERC20 token with controlled minting and burning
/// @author Yonko
/// @notice This token can only be minted by the WNM contract or WENBlocksManager
/// @dev Inherits OpenZeppelin's ERC20 and Ownable implementations
contract WUNIToken is ERC20, Ownable {
/// @notice Address of the WENBlocksManager
address public manageraddress;
/// @notice Address of the WNM (staking) contract
address public wnmAddress;
/// @notice Deploys the WUNIToken and mints initial supply to the deployer
/// @param name_ Name of the token (e.g. "WUNIToken")
/// @param symbol_ Symbol of the token (e.g. "WUNI")
constructor(
string memory name_,
string memory symbol_
) ERC20(name_, symbol_) Ownable(msg.sender) {
_mint(msg.sender, 2e18); // Mint initial supply to owner
}
/// @notice Restricts access to only WNM contract or WENBlocksManager
modifier onlyWNMandManager() {
require(msg.sender == wnmAddress || msg.sender == manageraddress, "Only the WENBlocksManager and WNM contract can trigger the mint function");
_;
}
/// @notice Sets the addresses allowed to call `mint`
/// @dev Callable only by the contract owner
/// @param _manageraddress The address of the WENBlocksManager
/// @param _wnmAddress The address of the WNM (staking) contract
function setAddresses(address _manageraddress, address _wnmAddress) external onlyOwner {
manageraddress = _manageraddress;
wnmAddress = _wnmAddress;
}
/// @notice Mints new tokens to a specified address
/// @dev Callable only by WNM or manager contracts
/// @param to The address to receive newly minted tokens
/// @param amount The amount to mint (must include full decimals)
function mint(address to, uint256 amount) external onlyWNMandManager {
_mint(to, amount);
}
/// @notice Burns tokens from the caller’s balance
/// @param amount The amount of tokens to burn
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
}
Last updated