1

I've deployed a very simple Contract to Testnet. It has the following function...

function transfer(address _to, uint256 _value) public
{
    /* Check if sender has balance and for overflows */
    require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]);

    /* Add and subtract new balances */
    balanceOf[msg.sender] -= _value;
    balanceOf[_to] += _value;

    /* Notify anyone listening that this transfer took place */
    Transfer(msg.sender, _to, _value);
}

Question: Does the standard Ethereum wallet actually call onto this function when I use the wallet to send my token, e.g., with this code am I implementing an abstract function that is declared in some base Contract? If yes, where can I look at the base Contract declaration? If no, how does the standard Ethereum wallet know how to transfer my tokens? Thanks.

2

I'm not sure what you mean by "the standard Ethereum wallet," but no, there is no base contract that all contracts inherit from.

Tokens like this work by implementing a standard known as ERC20, which nearly all tools for viewing and transferring tokens understand and consume.

  • By that I meant the Ethereum wallet that is included in Mist and linked to for download from the Ethereum website. But I think I understand now. Thanks very much. – patrickyc Dec 19 '17 at 13:25
  • Ah, yes, I assume that Mist has built-in understanding/support for ERC20 tokens. – smarx Dec 19 '17 at 13:26

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.