[Ethereum] How Ethereum token transfer works

balancestokenstransactions

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.

Best Answer

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.

Related Topic