0

I am not able to see the name, symbol, and supply on the smart contract at ropsten.

pragma solidity ^0.8.0;

contract MyToken{
address public minter;
mapping(address => uint) public balance;
string public name;
string public symbol;
uint256 public totalSupply;
uint8 public decimals;
event Sent( address from, address to,  uint amount);

constructor () {
minter = msg.sender; 
name = "COOP";
symbol= "COP";
totalSupply= 100 * 1000;
decimals= 18;


}

function mint(address recieve, uint amount) public {
    require(msg.sender == minter);
    balance[recieve] += amount;
}

function send(address reciever, uint amount) public {
    require(amount <= balance [msg.sender], "insuffient funds");
    balance[msg.sender] -= amount;
    balance[reciever] += amount;
    emit Sent(msg.sender, reciever,amount);
}

}

1
  • What do you mean with I am not able to see the name, symbol, and supply? They are public so you should be able to query them.
    – Ismael
    Oct 28 '21 at 0:12
0

This is because strings have to be read from the memory storage;

Declared like this

string  public symbol;
string  public name;

in a function or constructor as well

function setMyString(string memory myString) public {
   symbol = myString;
}

However, If your creating a token you should look at the ERC20 Standard to make sure you follow it and your token can be recognise by wallet and other contract.

To make an ERC20 you Must follow the standard. Look at Open Zeppelin Library that will provide you with a pre-made contract that you can reuse and customize.

11
  • When I declare the string it give me error. Oct 26 '21 at 20:11
  • I added the public statement. Try if this was your error. Giving error is meaningless unless you have an actual error message. Oct 26 '21 at 20:14
  • If you get an error it's probably not from that declaration. Oct 26 '21 at 20:15
  • the declaration is an error. Oct 26 '21 at 20:54
  • What is the error? Oct 26 '21 at 21:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.