3

I created a vanilla custom token via a contract on testnet and minted 10,000 coins to it, and I was able to successfully send the tokens to a wallet contract at a different address. However, when I attempt to use the Watch Token feature and paste the contract address, the balance is always zero, despite the form auto-loading the other contract variables.

Shouldn't the number next to the icon display the amount of custom tokens associated with the main account address?

I am using Mist 0.8.10 on ropsten testnet.

Custom Token Contract details

My contract is pretty simple:

pragma solidity ^0.4.11;

contract PractCoin {

    mapping (address => uint256) public monies;
    address public owner;
    uint public totalCoins;
    uint public initialSupply;
    string public name;
    uint8 decimalPlaces;

    function PractCoin(uint _totalCoins, uint _initialSupply, string _name, uint8 _decimalPlaces){
        owner = msg.sender;
        totalCoins = _totalCoins;
        initialSupply = _initialSupply;
        monies[owner] = initialSupply;
        name = _name;
        decimalPlaces = _decimalPlaces;
    }

    function sendCoins(address _to, uint _amount){
        if (monies[msg.sender] < _amount || 
            msg.sender == _to || 
            monies[_to] + _amount < _amount) throw;
        monies[msg.sender] -= _amount;
        monies[_to] += _amount;
        CoinTransfer(_amount, _to, msg.sender);
    }

    function destroyContract(){
        if (msg.sender == owner ) selfdestruct(owner);
        ContractDestroyed("Contract Destroyed!");

    }

    event CoinTransfer(uint _amount, address indexed _to, address indexed _from);
    event ContractDestroyed(string _message);
}
1
  • Yes ok i am very happy this and i intresst
    – Abdi ahmed
    Commented Jun 23, 2018 at 10:06

1 Answer 1

7

Your contract is not ERC20 compliant. It is very important to retain the ERC20 standard, which means keeping all names the same. See this definition contract. Mist should be looking for the following properties, per ERC20:

uint public supply;
string public name;
uint8 public decimals;
string public symbol;
string public version;

You should also include all of the following functions to be ERC20 compliant:

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

function balanceOf( address who ) constant returns (uint) {
  return balances[who];
}

function transfer( address to, uint value) returns (bool) {
  balances[msg.sender] = safeSub(balances[msg.sender], value);
  balances[to] = safeAdd(balances[to], value);
  Transfer( msg.sender, to, value );
  return true;
}

function transferFrom( address from, address to, uint value) returns (bool) {
  approvals[from][msg.sender] = safeSub(approvals[from][msg.sender], value);
  balances[from] = safeSub(balances[from], value);
  balances[to] = safeAdd(balances[to], value);
  Transfer( from, to, value );
  return true;
}

function approve(address spender, uint value) returns (bool) {
  approvals[msg.sender][spender] = value;
  Approval( msg.sender, spender, value );
  return true;
}

function allowance(address owner, address spender) constant returns (uint) {
  return approvals[owner][spender];
}

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.