ERC-20 Metadata

Extension of ERC-20 that adds the optional metadata functions from the ERC20 standard.

Usage

In order to make ERC-20 Metadata methods “external” so that other contracts can call them, you need to add the following code to your contract:

use openzeppelin_stylus::{
    token::erc20::{
        extensions::Erc20Metadata,
        Erc20,
    },
};

sol_storage! {
    #[entrypoint]
    struct Erc20Example {
        #[borrow]
        Erc20 erc20;
        #[borrow]
        Erc20Metadata metadata;
    }
}

#[external]
#[inherit(Erc20, Erc20Metadata, Capped, Pausable)]
impl Erc20Example {
    // ...
}

Additionally, you need to ensure proper initialization during contract deployment. Make sure to include the following code in your Solidity Constructor:

contract Erc20Example {
    // ...

    string private _name;
    string private _symbol;

    constructor(string memory name_, string memory symbol_) {
        // ...

        _name = name_;
        _symbol = symbol_;

        // ...
    }
}