How tokens are transferred?

The following question has been asked on Telegram:

[In the FA2 contract] where in the transfer method is it making it appear in the target wallet address as by the looks it only keeps an internal ledger of balances per wallets and not using the sp.transfer command in the smartpy example code there?

The FA2 (TZIP-12) is a token standard on the Tezos blockchain, the specification for which can be found here. In FA2 contracts, token ownership and balances are managed through a storage field, commonly named ledger. This ledger effectively functions as an internal record-keeping mechanism, mapping wallet addresses to their respective token balances.

When a token transfer operation occurs using the transfer entrypoint in an FA2 contract, the contract doesn’t actually send tokens to an external wallet. Instead, it modifies the ledger by deducting the transferred amount from the sender’s balance and adding it to the recipient’s balance.

Wallets and block explorers, like Temple, TzKT and Better Call Dev, use indexers to scan and interpret blockchain activity. These indexers monitor changes in all contracts and maintain a record of token ownership. So, when a user looks up their balance in a wallet or explorer, what they are seeing is a representation of the token contract’s internal ledger, fetched and displayed in a user-friendly manner.

Currently, there are proposals for new standards that leverage the Tezos ticket system to represent tokens. If adopted, this approach would allow tokens to reside directly within wallets, changing the current paradigm.