1

I am trying to write a Smart Contract to generate Staking Rewards for an existing Cryptocurrency But I've been getting this error

Contract "Stakeable" should be marked as abstract

How do I fix this?

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// import "@openzeppelin/contracts/access/Ownable.sol";
// import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Stakeable is ERC20, Ownable{
        using SafeMath for uint256;
    
        string private constant _name = "Schrodinger";
        string private constant _symbol = "Kitty Dinger";
        
        /**
        * @notice We usually require to know who are all the stakeholders.
        */
        address[] internal stakeholders;
    
        /**
         * @notice The stakes for each stakeholder.
         */
        mapping(address => uint256) internal stakes;
    
        /**
         * @notice The accumulated rewards for each stakeholder.
         */
        mapping(address => uint256) internal rewards;
    
        /**
        * @notice The constructor for the Staking Token.
        * @param _owner The address to receive all tokens on construction.
        * @param _supply The amount of tokens to mint on construction.
        */
    
        constructor(string memory name_, string memory symbol_, address _owner, uint256 _supply)
        {    
            name_ = _name;
            symbol_ = _symbol;
            _mint(_owner, _supply);
        }
1
  • Btw in solidity v0.8.0+ you don't have to use SafeMatch library anymore. Solidity is checking over/underflows automatically. In case you would like to turn it off for some part, use unchecked { ... }
    – ashhanai
    Commented Apr 3, 2022 at 17:57

2 Answers 2

3

@ashhanai has a good point.

You are inheriting your contract from ERC20 but you didn't call the ERC20 constructor. If you'll update your constructor as like @ashhanai's suggestion, probably the problem will disappear.

1

Don't set the name and symbol properties directly, add call to ERC20 constructor instead.

Update constructor code:

constructor(string memory name_, string memory symbol_, address _owner, uint256 _supply) ERC20(name_, symbol_)
    {    
        _mint(_owner, _supply);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.