_mint function for IERC20 Safemoon fork?


I am trying to implement a new function to the safemoon protocol i found on the web. You can find it here: https://github.com/safemoonprotocol/Safemoon.sol .

I am using remix to edit code.

So the function i am trying to add looks like this:

function mint(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;

When i try to compile it, i get an error looking sort of like this: (excluded line of error and name of project as it has no value)

declarationerror: Undeclared identifier. Did you mean “mint”? → _mint(_msgSender(), amount);

So i am struggeling here as i dont know whats wrong…

I tried to remove the underline before mint and deploy it. I only got a warning, but the result when deploying wasn’t as expected.

I may think this is due to the contract is IERC20 and not ERC20, but not sure about it?

Any help on this would be very appreciated!
Thank you in advance :slight_smile:

Here is bscscan info w/ verified contract if neccessary to have a look: https://bscscan.com/token/0x635484bbaadfb5834decc52cc0debf2c09c4c662

_mint is not part of the ERC20 standard. Recent versions of ERC20 contracts may have this function, but it is not in the interface. Besides, even it is in IERC20, that's not how you can mint tokens for Safemoon-ish contracts, since _rOwned and _tOwned are not consistent with _balances that _mint can work with.

1 Like