CLETH Contract

The CLETH contract operates as an ERC20 token but with expanded functionalities tailored for minting, burning, pausing functionalities, managing rewards, and assigning roles to other contracts or addresses. Here's an overview of its functions:

Functions

  1. mint(address to, uint256 amount):

This function mints CLETH tokens and assigns them to a specified address. It requires the role of MINTER_ROLE and operates only when the contract is not paused.

function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) whenNotPaused{n
   require(amount > 0, "CLETH: mint amount must be greater than zero");
   _mint(to, amount);
}
  1. burn(address from, uint256 amount):

The burn function removes CLETH tokens from a specified address. It requires the BURNER_ROLE and operates only when the contract is not paused.

function burn(address from, uint256 amount) external onlyRole(BURNER_ROLE) whenNotPaused {
   require(amount > 0, "CLETH: burn amount must be greater than zero");
   _burn(from, amount);
}
  1. addReward, setReward:

These functions adjust reward amounts for users. addReward increases the reward for an account, while setReward sets a specific reward amount. Both functions require the MINTER_ROLE.

function addReward(address account, uint256 amount) public onlyRole(MINTER_ROLE) {
       rewards[account] += amount;
   }
   function setReward(address account, uint256 amount) public onlyRole(MINTER_ROLE) {
       rewards[account] = amount;
   }
  1. claimReward(address account):

Users can claim their accumulated reward tokens. The function checks for available rewards, resets the reward amount, and mints the claimed reward tokens for the user.

 function claimReward(address account) public {
       uint256 reward = rewards[account];
       require(reward > 0, "No rewards to claim");
       rewards[account] = 0;
       _mint(account, reward);
   }
  1. pause() and unpause():

These functions respectively pause and unpause the minting and burning functionalities of the token. They require the PAUSER_ROLE.

function pause() public onlyRole(PAUSER_ROLE) {
       _pause();
   }


   function unpause() public onlyRole(PAUSER_ROLE) {
       _unpause();
   }
  1. grantRoles(address stakingMaster):

This function assigns roles (MINTER_ROLE, BURNER_ROLE, and PAUSER_ROLE) to another contract or address. It's accessible only by the DEFAULT_ADMIN_ROLE.

function grantRoles(address stakingMaster) external onlyRole(DEFAULT_ADMIN_ROLE) {
    grantRole(MINTER_ROLE, stakingMaster);
   grantRole(BURNER_ROLE, stakingMaster);
   grantRole(PAUSER_ROLE, stakingMaster);
}

Last updated