Using the Burnable class

Hi, everybody. I am new here and I am just getting my hands dirty on the Solidity and openZeppelin.

The issue I have is that I want to use the


class in my contract address. Will I just call

function burn

like this?

contract SpongeBob is Context, IERC20, ERC20Burnable, Ownable {
    // Excluding other codes
    event Burn(address indexed burner, uint256 value);
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);

   function _burn(address _who, uint256 _value) internal {require(_value <= balances[_who]);

Is this the way to call it?

It is my understanding that by simply extending the ERC20Burnable contract, you can call Burnable methods such as burn() and burnFrom() directly through an instance of your contract. No need to expose them again in your contract unless you are specifically overriding some parent functionality of the contract.

Open Zeppelin contracts can be extended and used as is.

Hope this helps.

1 Like

Just call the functions from openZeppelin no need for the logic in your contract

Just like i said, I am new to Solidity and zepellin. If I were to use it the way we do use it in PHP ( which I am largely familiar with ), I did just do something like this

burnFrom(account, amount);

Doing it this way is returning an error

ParserError: Expected identifier but got '('
--> contracts/BillWorth.sol:935:9:
935 | burn(amount);
| ^

I don't know if this is not the actual way to call it in Solidity.

PS: I am already going through the Solidity doc to get familiar with the Solidity language

Take a look at Contracts Wizard to see how to include burn functionality in your token:

As for how to invoke this functionality, that depends on whether you want to invoke it from "outside" the blockchain e.g. from a web app, or from "inside" the blockchain i.e. from another Solidity smart contract.

I am happy I got your attention. Actually, it was in one of your suggestions to another newbie then about the newbie going through the solidity doc and solidity examples that got my interest about learning it from scratch instead of just the copy-paste I have been using for quite a while now.