0

I've recently created a smart contract on Fantom and wondered about a few details:

  • Mint Functions
  • Burn Functions

Can any users or developers interact with these functions. For example, with my newly created tokens. If I were to send these to another user, can they just burn them? Or can they just mint more?

How are these functions governed?

Example burn function:

 function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);
    }

Thanks.

2 Answers 2

0

This depends on the implementation of smart contracts. Usually, burn and mint functions have some sort of modifier that limits others from calling them. But sometimes, the implementer of the contract makes mistakes and exploits such as crypto-burger.

In your example, it is an internal function meaning it is called only inside your contract. But since you haven't posted all code, it's hard to say who can call or can't.

2
  • Thanks for the reply, these were just made in remix. atm Im just using them to create test transactions with metamask. But smart also contains this: (see my next comment)
    – ozftm
    Commented Aug 17, 2022 at 16:33
  • abstract contract ERC20Burnable is Context, ERC20 { function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } }
    – ozftm
    Commented Aug 17, 2022 at 16:34
0

you can use OpenZeppelin's Access Controls to add restrictions around whos allowed or not allowed to interact with your contracts functions. See more info here:

https://docs.openzeppelin.com/contracts/2.x/access-control

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.