Search code examples
ethereumsmartcontracts

Can an ethereum smart contract address hold many types of tokens?


I know that an ethereum funds address can hold many types of tokens. If the address is a contract address, can it also hold many types of tokens? or it can only hold the token it defines?

In other words, is it true that any address in ethereum can:

  1. have at most one smart contract attached to it. This allows other users to locate this smart contract.
  2. have arbitrary types of tokens attached to it. The address here allows other smart contract to keep track of the balance this address owns.

^ Is this correct? Thanks.


Solution

  • Both your assumptions are correct.


    I'll just clear out the fact that it's not the "owner" address holding the tokens per se. The information which address owns how many tokens (or which tokens, in case of NFTs) is stored on each token contract. Also, blockchain explorers (such as EtherScan or BscScan) aggregate this data in their off-chain databases, so it's easier to search on their site.

    Example:

    • Contract 0x123 (token ABC) holds the information that Address A owns 1 ABC token.
    • Contract 0x456 (token DEF) holds the information that Address A owns 2 DEF tokens.
    • A blockchain explorer has all this info aggregated in their off-chain DB, so that users can simply filter "all tokens by Address A" and they don't have to keep querying all token contracts asking "How many of your tokens does Address A own?".