ERC20 Tokens
Introduction to ERC20 Tokens
ERC20 is currently the dominant approach to implementing fungible, blockchain-based tokens. Each ERC20 token is based on the original ERC20 token interface, meaning that they all share a common set of functions, including (but not limited to):
Transferring tokens from one account to another;
Getting the current token balance of an account;
Getting the total supply of the token available on the network;
Approving an amount of tokens to be spent by a third-party account;
In order to be ERC20 compatible, a token must implement all the following functions and events:
Best Practices
ERC20 is a simple, secure standard. But we must be careful in our implementation; many ERC20 tokens have been exploited over the years due to the inclusion of additional, buggy code.
For safety and security, we recommend using the OpenZeppelin ERC20 implementation for your project, the source code for which can be found at ERC20.sol. You can do this with the following steps:
1. Install OpenZeppelin smart contracts in your project by running the following command:
npm install @openzeppelin/contracts
2. Then, you can import the contracts in the library with this:
You can find more information on OpenZeppelin ERC-20 implementation here.
References
Last updated