Today’s food for thought we look at the Ethereum token creation conventions, namely the ERC20 and ERC223 standards. This can be especially helpful to developers new to solidity and want to create a token on it. Understanding this can also help investors in making their investment decisions for ICO.
Theoretically, smart contract on Ethereum blockchain can be arbitrary designed if there is no syntax error within Solidity. However, for several third-party software such as Myetherwallet and Mist to have easy access to your smart contract, a set of conventions has been decided for token creation smart contracts. These conventions include variables, functions and their names. Ethereum token developers are strongly recommended to follow this set of conventions, otherwise their tokens may not be recognized by ethereum wallets. Most people have probably heard of ERC20 token standards. This article will mainly focus on how ERC223 standards has improved on ERC20.
ERC20 guarantees the token created to have simple transferability among wallets and contracts. There are three functions: ‘transfer’, ‘transferFrom’ and ‘allow’ that must exist in every ERC20 contract. People can simply use ‘transfer’ to send their tokens and if someone wants to spend token reside in a contract, the contract must first ‘allow’ the spender before the spender can ‘transferFrom’ token from that contract.
As the version of Solidity and Ethereum virtual machine updates, more functions are available and a new set of stardard, namely ERC223 has been created. ERC223 is backwards compatible with ERC20 meaning every software that supports ERC20 will also supports ERC223. In additions, ERC223 merges the token transfer function among wallets and contracts into one single function ‘transfer’. The biggest change is that ERC223 no longer allow token to be transferred to a contract that does not allow token to be withdrawn. Before ERC223, if someone send his/her token into a contract that has not allowed anyone to use it, the token will simply be locked and can never leave that contract. Because of this, hundreds of thousands of dollars’ worth of ERC20 token has been locked up. Merging functions can also save transaction fees in terms of gas.
3 Primary improvements with ERC223
- Eliminates the problem of lost tokens which happens during the transfer of ERC20 tokens to a contract (when people mistakenly use the instructions for sending tokens to a wallet). ERC223 allows users to send their tokens to either wallet or contract with the same function transfer, thereby eliminating the potential for confusion and lost tokens.
- Allows developers to handle incoming token transactions, and reject non-supported tokens (not possible with ERC20)
- Energy savings. The transfer of ERC223 tokens to a contract is a one step process rather than 2 step process (for ERC20), and this means 2 times less gas and no extra blockchain bloating.
Switching from ERC20 to ERC223
ERC223 tokens are backwards compatible with ERC20 tokens. It means that ERC223 supports every ERC20 functionality and contracts or services working with ERC20 tokens will work with ERC223 tokens correctly.Sources: https://github.com/Dexaran/ERC23-tokens/tree/Recommended#erc23-token-standard(ERC23 and 223 are the same thing). To read the full discussion about ERC20 and ERC223, follow this link: https://github.com/ethereum/EIPs/issues/223