1

Before the question, I want to list my development environment configuration:

  • I am using Remix online solidity IDE for coding
  • My contract is running on local PC with RPC (web3 provider option in Remix)
  • I set up MEW to run on my http:127.0.0.1:8545 node

I managed to deploy my ERC20 token contract, adding it to the MEW list that displays the current amount on that account; however, even though in the contract I set 10000000 as the initial supply of tokens, MEW displays '0.000 1e-11 RC' as the total amount. What am I missing out?

The code:

pragma solidity ^0.4.0;

contract UnclearlyToken {

    string public constant name = "Unclearly";
    string public constant symbol = "UC";
    uint8 public constant decimals = 18;
    uint totalAmount = 10000000;

    mapping (address => uint256) public balances;
    mapping(address => mapping (address => uint256)) allowed;

    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);

    function UnclearlyToken() {
        balances[msg.sender] = totalAmount;
    }

    function totalSupply() constant returns(uint) {
        return totalAmount;
    }

    function balanceOf(address _owner) constant returns(uint256) {
        return balances[_owner];
    }

    function transfer(address _to, uint _value) returns (bool success) {
        if(balances[msg.sender] >= _value 
            && _value > 0 
            && balances[_to] + _value > balances[_to]) {

            balances[msg.sender] -= _value;
            balances[_to] += _value;
            Transfer(msg.sender, _to, _value);

            return true;
        }
        return false;
    }

    function transferFrom(address _from, address _to, uint _value) returns (bool success) {
        if(balances[_from] >= _value
            && _value > 0 
            && balances[_to] + _value > balances[_to]
            && allowed[_from][msg.sender] >= _value) {

            balances[_from] -= _value;
            balances[_to] += _value;
            Transfer(_from, _to, _value);

            return true;
        }
        return false;
    }

    function approve(address _spender, uint _value) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);

        return true;
    }

    function allowance(address _owner, address _spender) constant returns (uint remaining) {
        return allowed[_owner][_spender];
    }
}

MEW side:

enter image description here

1

Ok, sorry for the question, it's quite simple. You just need to change the decimals of your token. See this discussion for more details: Float not allowed in solidity vs decimal places asked for token contract

  • 1
    Hi there. If you think your question will be useful to other people in future, can you add a few more details to your answer to make it clearer what you did to solve the problem? :-) – Richard Horrocks Jul 13 '17 at 9:34
  • Sure, just a min. – Paolo Guerra Jul 13 '17 at 9:46

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.