0

I'm working on a local environment by Truffle and Ganache so that MetaMask is set to it. I created an ERC20 token there and imported it to MetaMask according to this guide. But, MetaMask doesn't list my token. What is wrong and what should I do?

This is the token whole code:

    // SPDX-License-Identifier: MIT
    
    pragma solidity ^0.8.0;
    
    contract myToken{
        string public name='aToken';
        string public symbol='ATN';
        string public standard='aToken v0.1';
        uint8 public decimals=18;
        uint public totalSupply;
        address Owner;
    
        mapping (address => uint) public balanceView;
        mapping (address => mapping(address => uint)) public allowing;
    
        event Transfer(address indexed _from, address indexed _to, uint256 _value);
        event Approval(address indexed _owner,address indexed _spender ,uint256 _value);
        event Burning(address indexed _owner,address indexed _outerTo, uint256 _value, address _twinContract);
        event Minting(address indexed _outerFrom,address indexed _to, uint256 _value, address _twinContract);

        function initial(uint _value) public{
            totalSupply=_value;
            balanceView[msg.sender]+=_value;
            Owner=msg.sender;
            emit Transfer(0x0000000000000000000000000000000000000000,msg.sender,_value);
        }
    
        function transfer(address _to, uint256 _value) public{
            require(balanceView[msg.sender]>=_value, 'BALANCE NOT ENOUGH');
            balanceView[msg.sender]-=_value;
            balanceView[_to]+=_value;
            emit Transfer(msg.sender,_to,_value);
        }
    
        function approve(address _spender,uint256 _value) public{
            allowing[Owner][_spender]+=_value;
            emit Approval(Owner,_spender,_value);
        }
    
        function transferFrom(address _from, address _to, uint256 _value) public{
            require(balanceView[_from]>=_value, 'BALANCE NOT ENOUGH');
            require(allowing[Owner][_from]>=_value, 'PAYMENT IS NOT ALLOWED');
    
            balanceView[_from]-=_value;
            balanceView[_to]+=_value;
    
            allowing[Owner][_from]-=_value;
    
            emit Transfer(_from,_to,_value);
        }
    
        function balanceOf(address _owner) public view returns(uint256){
            return balanceView[_owner];
        }
        function allowance(address _owner,address _spender) public view returns(uint256){
            return allowing[_owner][_spender];
        }
    
        function burn(address _outerTo,uint256 _value,address _contract) public{
            require(balanceView[msg.sender]>=_value,"Your balance is low!");
            balanceView[msg.sender]-=_value;
            allowing[Owner][msg.sender]-=_value;
            emit Burning(msg.sender,_outerTo,_value,_contract);
        }
    
        function mint(bool status,address _outerFrom, address _to, uint256 _value, address _contract) public{
            require(status,"Accoutn is not allowed to mint");
            require(balanceView[Owner]>=_value);
            balanceView[Owner]-=_value;
            balanceView[_to]+=_value;
            emit Minting(_outerFrom,_to,_value,_contract);
        

}
}

The below photo shows my assets list in MetaMask.

enter image description here

2
  • We would need some more code to be able to assist. Are the token code correct? is it created using ERC20 standard so metamask can recognize it?
    – Akall
    Mar 14 at 18:22
  • @Akall I added the code to the question now!
    – Alireza
    Mar 15 at 5:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.