Skip to main content

Type a word from a question or an article title.

1 · Basics

Tokens and NFTs - what they are, how they differ and where they are used

An overview of tokens on Ethereum - fungible (ERC-20) and unique (NFTs, ERC-721 and ERC-1155), how they work, where they are used and what risks they carry.

3 min readUpdated:
In this article

On the Ethereum blockchain there are two kinds of "things": coins you can pay with, and tokens - records that represent something: a dollar, a ticket, a place in a game, a voting right. Let us see how they work and how they differ.

A token is a table in a contract

A reminder: a smart contract is a program with its own memory. The simplest token is a contract with an "address → amount" table and a few functions: "transfer", "show balance". When you "send USDT" you call a function of that contract and it changes the numbers in its table (more on the mechanics). There are no "coins" in a wallet - there is a record in the token's table.

A token differs from the network's main coin (ETH, POL, BNB) in that it is not built into the protocol: its rules are set by a specific contract's code. Good tokens follow common standards so that wallets and apps handle them the same way.

Fungible tokens: ERC-20

ERC-20 is a standard where all units are alike, like roubles or dollars: one USDT is indistinguishable from another. The standard defines a set of functions:

FunctionWhat it does
balanceOf(address)shows the balance
transfer(to, amount)transfers tokens
approve(spender, amount)allows another address to spend your tokens
transferFrom(from, to, amount)transfers on permission
decimals()how many decimal places

This is how the stablecoins USDT, USDC, DAI, governance tokens and "wrapped" coins are built. These are exactly the tokens our service accepts, plus the network's main coin. The subtleties are in the articles on approve and non-standard tokens. And how to write such a token yourself is shown in the article ERC-20 from scratch.

Unique tokens: NFTs

An NFT (non-fungible token) is a token where every unit is unique and has its own number. It is like a theatre ticket with a seat number: two tickets to the same show are not equal if the seats differ.

ERC-721 is the main NFT standard:

  • each token has a number (tokenId);
  • the ownerOf(tokenId) function shows the owner;
  • a token can be transferred whole, but not "in parts".

ERC-1155 is a hybrid: one contract holds both fungible and unique tokens, and they can be transferred in batches. Games like it: "100 gold coins" and "sword #4821" live in one contract.

Where NFTs are used

  • Digital art and collectibles - the best-known use, behind NFT popularity in 2021.
  • Tickets and passes. A concert ticket as an NFT is hard to forge and easy to check at the door.
  • In-game items that can be owned outside the game.
  • Domain names. The .eth names in ENS are NFTs.
  • Membership and access to communities and services.
  • Proof of rights over real things (a carrier of the ownership record).

What is stored on the blockchain and what is not

An NFT's image usually is not on the blockchain: it is too large and expensive. The token stores a link (tokenURI) to a description and image sitting on an ordinary server or in distributed storage like IPFS.

Token risks

  • Fake tokens. Anyone can issue a token named "USDT". Check the contract address, not the name (how to check).
  • Blocking and pausing. With centralised stablecoins the issuer can block an address (more).
  • Contract vulnerabilities. A token is a program too, and programs have bugs (catalogue of vulnerabilities).
  • Phishing through approvals. Tokens ask to be "approved" - scammers exploit this (how to protect yourself).
  • Liquidity. A token is "worth" what it can actually be sold for.

Tokens in Coin-Trust

The service works with the network's main coin and a whitelist of ERC-20: USDT, USDC, DAI (the set depends on the network). NFTs and arbitrary tokens are not accepted by the contract: this is protection against tokens with non-standard behaviour. More on the protection in the article on non-standard tokens.

Tokens are the basis of applications called DeFi: dApps and decentralised finance. And if you want to recall a term quickly, see the glossary.

Mentioned in

Ready to try it?

Create your first deal in a couple of minutes. The money is locked in a smart contract and paid out by rules you can see in advance.