Fungible tokens imply that there is equal value between the assets being considered. The definition of fungible is "mutually interchangeable".
Fungible tokens have the following properties:
interchangeable - a fungible token can be exchanged with other tokens of the same type. An example of this is if I give you one fungible token and you give me one back, then it makes no difference in terms of value to the two of us.
uniform - fungible tokens are all of the same type and identical in specification, functionality and valuation method.
divisible - a fungible token can be broken down into smaller units. Each will still represent a part of the larger token.
Fungible Token Standards#
A popular implementation of fungible tokens is the ERC-20 token standard. Tokens can be created with Solitiy smart contracts and sent to the Ethereum blockchain. These token smart contracts can be used to represent value and be held by Ethereum accounts (wallets, other smart contracts, etc.).
To create an ERC-20 token with Solidity, there are different methods and events that need to be implemented. The methods and methods are predefined in something called a smart contract interface. The interface is written in Solidity. The token smart contract that we will write will inherit from the interface we create. The interface we create will have all of the requirements of the ERC-20 token standard found here.
ERC-20 Token Standard#
The ERC-20 Token Standard helps developers write Solidity (or any coding language) for token smart contracts. The ERC-20 Token Standard defines requirements for the token smart contracts (e.g. methods, events, variables) that need to be implemented.
For an ERC-20 token implementation, two events are required: Transfer and Approval.
The Transfer event must be triggered when tokens are transferred, even for zero-value transfers. The Transfer event should also be called when a token contract creates new tokens. The
_from field should be set to
The Approval event must be called whenever the
approve method is called, which we will explore in the next section on Methods.
In addition to events, the ERC-20 token that we are creating with Solidty also has a set of methods that require implementation. They include the following.