6

I created an ERC20 token using the ERC20Interface, but it's classified as ERC721 on the Mumbai polygon scan. What can be the reason?

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function decimals() external view returns (uint8);
    function symbol() external view returns (string memory);
    function name() external view returns (string memory);
    function getOwner() external view returns (address);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address _owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 indexed value);
    event Approval(address indexed owner, address indexed spender, uint256 indexed value);
}

contract MyToken is IERC20 {
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => uint256) internal _balances;

    uint256 public _totalSupply;
    uint8 public _decimals;
    string public _symbol;
    string public _name;
    address public owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    constructor() {
        owner = msg.sender;
        _name = "MyToken";
        _symbol = "MTK";
        _decimals = 0;
        _totalSupply = 1000000;
        _balances[owner] = _totalSupply;

        emit Transfer(address(0), msg.sender, _totalSupply);
    }

enter image description here

Thank you

1 Answer 1

6

The reason is that the event Transfer has the amount indexed. This is a patter of ERC721 and not ERC20.

Consider changing:

event Transfer(address indexed from, address indexed to, uint256 indexed value);

to:

event Transfer(address indexed from, address indexed to, uint256 value);

Also the same for Approval.

1
  • 1
    Thank you. It worked. I set them as event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); Aug 28, 2022 at 16:24

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.