2

Does an account get actual tokens when you call a transfer function in an Ethereum token contract or is it just a balances mapping that registers how many tokens each account (address) has?

I am trying to figure out the difference between sending Ether (which in my opinion are real units which can be transferred from one account address to another and a token created by a smart contract is in my opinion only registered in the bookkeeping of the smart contract itself, right?

Can I say that Ether is registered in the Ethereum ledger and a Token in the ledger of a smart contract? Correct me if I am wrong.

4

That is absolutely correct. A token-contract is nothing more than a mapping between address => balance. When transferring tokens, you don't really receive them the way you expect them to be received as you would receive ether for example. The mapping with your address as index is just incremented by the amount "sent" to your address, and the sender's balance is decremented.

https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol is a Standard Token implementation of the ERC20 token standard, which shows you exactly how it's done.

  • Thanks for you answer! So when people talk about sending tokens it is actually bookkeeping in the contract's ledger, right? – Robbert Sep 12 '17 at 12:28
  • that is correct. – Qkyrie Sep 12 '17 at 12:42
  • Okay, but why is the ERC23 token proposed then? github.com/ethereum/EIPs/issues/223 – Robbert Sep 12 '17 at 12:44
  • 1
    That's basically a proposal to build some extra functionality. In a normal ERC20, when you initiate a transfer, just the balances are changed in the mapping. This results into 2 problems. 1) you can't react on any incoming transactions, as it's just a change in the bookkeeping 2) if you transfer tokens to a contract, the only entity that can transfer them from the contract to another address would be the contract. If your contract doesn't know how to do this (which most contracts can't), the tokens would be stuck forever. ERC223 aims to solve these issues, by trying to work out a standard. – Qkyrie Sep 12 '17 at 12:56

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.