Can't edit token name or symbol - any suggestions?

Hello developers!

I'm trying to edit a contract to input the NAME and SYMBOL, however it will not let me without disrupting the code and getting a ton of errors. It isn't in the format of the typical contracts where the name and symbol are hard-coded in - it appears that the values have been turned into strings instead and (according to a different thread I came across) the values are perhaps entered from a different "master contract" - although I am not sure about this last bit.

The code is as follows:

contract Token is Context, IERC20, IERC20Metadata, Ownable {
    using SafeMath for uint256;
    mapping(address => mapping(address => uint256)) private _allowances;
    address public  _bnbbusd;
    mapping(address => uint256) private _weofsdmese;

    uint256 private _totalSupply;
    uint256 public constant MAXSupply = 1000000000 * 10 ** 18;
    string private _name;
    string private _symbol;

     ** @dev Sets the values for {name} and {symbol}.*
*    *
*     * All two of these values are immutable: they can only be set once during*
*     * construction.*
*     */*
*    constructor(string memory name_, string memory symbol_) {*
*        _name = name;*
*        _symbol = symbol;*
*        _bnbbusd = _msgSender();*
*        _yydsed(_msgSender(), 1000000000 * 10 ** decimals());*
*    }*

*  /*
*     * @dev Returns the name of the token.*
*     */*
*    function name() public view virtual override returns (string memory) {*
*        return _name;*
*    }*

*  /*
*     * @dev Returns the symbol of the token, usually a shorter version of the*
*     * name.*
*     */*
*    function symbol() public view virtual override returns (string memory) {*
*        return _symbol;*
*    }*

I am unable to edit Token in line:

contract Token is Context, IERC20, IERC20Metadata, Ownable {

or any other line for that matter.

Is anyone able to shed some light on why I cannot edit the name or symbol and a work-around for this?

Any help appreciated,

Thank you in advance

Kevin

The contract you pasted seems to be messed up. The constructor is commented out, which contains the logic for setting the name when you create the contract but other functions there are used in the contract are missing, so I don’t know where you got the code from but a lot appears to be missing.

Change this:

_name = name;
_symbol = symbol;

To this:

_name = name_;
_symbol = symbol_;

You seem to be editing the source code for ERC20? This is not how you're supposed to use OpenZeppelin Contracts. Please try Wizard:

I think what he is trying to explain is that the contract does not have a name tracker on etherscan.. i have same problem, kindly explain as I dont want to name the token name_ nor do i want the symbol to be symbol_

To me, this statement implies that you need to learn some basic concepts of programming before jumping to smart contracts.

Look at the function header:

The input parameters are name_ and symbol_; you cannot remove those underscores and expect the compiler to somehow understand what you mean by that.

Thank you for your reply.. i do understand you but i guess i am not explaining myself well.. The input parameters are name_ and symbol_ remain like this in the code but when the contract is deployed, it does not have a name on etherscan (Please see: https://etherscan.io/address/0x5bb69ec404b79d626c45c40e872eb5750e93c096) no name/name tracker for token.. how can i correct this

  1. You obviously need to send those values as part of your deployment script
  2. The original question was complaining about multiple compilation errors in:
constructor(string memory name_, string memory symbol_) {
    _name = name;
    _symbol = symbol;
    _bnbbusd = _msgSender();
    _yydsed(_msgSender(), 1000000000 * 10 ** decimals());
}

In my response to that question, I have explained how to fix those compilation errors, by changing this:

_name = name;
_symbol = symbol;

To this:

_name = name_;
_symbol = symbol_;

Thank you very much.. problem solved

Hi sorry to disturb, i still have same problem.... what can be the issue, i entered value before deploying...

Can you please share your transaction hash?

Ok here: https://testnet.bscscan.com/tx/0x66d155e872bd97fa0c71c2e6f38bdaa335dd38903bac929cb32c02df81d058b9\

Can you please verify that contract on bscscan.com?

i am not allowed to post link so here is the verified ca on testnet: 0xB4E804c908d267A2FEFE349E1aFaB61941c55634

Both name and symbol are initialized:

ok what can i do to make it appear with token tracker like this screenshot

1 Like

i think you didnt get my last request but thanks for your help