What is a token, really?
A technical explanation of what a DOGE Coin, Shiba Inu (SHIB) Coin, or FTT token is.
First, there are two main types of tokens: native tokens and programmatic tokens.
Bitcoin and Ether are native tokens – transfers and balances are built directly into the protocol. When you send an Ethereum transaction, you can optionally attach an amount – which can only be denominated in Ether. Balances aren't directly stored on the Blockchain; only transfers are recorded (in practice, most nodes keep track of balances as well).
The second type of token is a programmatic token or token standard. These tokens exist on blockchains that expose a general computing layer, like Ethereum. In this case, these tokens are simply programs that implement a certain interface. For most tokens, that's ERC-20.
For example, on Ethereum, any program that implements the following methods is considered a "token."
function name() public view returns (string)
function symbol() public view returns (string)
function decimals() public view returns (uint8)
function totalSupply() public view returns (uint256)
function balanceOf(address _owner) public view returns (uint256 balance)
function transfer(address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function approve(address _spender, uint256 _value) public returns (bool success)
function allowance(address _owner, address _spender) public view returns (uint256 remaining)
In addition, every time a transfer is executed, it must emit a Transfer
event.
Ether itself is not an ERC-20, although there's a contract "wrapped ETH" that lets you treat it as such.