-
The creation of a token standard allows for consistent interoperability between wallets, tokens, and dApps. The standardization of functions within the ERC-20 token code means that all developers writing code to interact with these tokens are using the same language (i.e. all using “totalSupply()” as opposed to some using “totalSupply” and some using “maxSupply” or “getTotalSupply”).
-
According to the Ethereum development wiki, these are the functions an ERC-20 must implement:
-
totalSupply()
determines the maximum number of this ERC-20 tokens that will exist -
balanceOf()
is used to query the amount of this ERC-20 token on any given Ethereum wallet address -
allowance()
dictates the amount of a token that the smart contract is allowed to transfer from one address (address owner
) to another (address spender
). This means the smart contract will never remove more than the designated amount from the wallet of theaddress owner
-
transfer(address recipient, uint256 amount)
transfers the designated amount of tokens from the message sender to the designated address. No checks are made on the recipient address, so sender must ensure correct address.- For some reason the SC doesn’t have access to the senders address @ time of execution, so the need for the following two functions arises
-
approve()
is the first part of a two-step process (incl.transferFrom()
that allows a token holder to approve a certain number of tokens to be removed from their address (usually to be sent to a SC) -
transferFrom()
is used to send theapprove()
amount of tokens from a given address to another given address
Oh heck yeah, that was a lot of work but dang I know more about this ERC-20 business. I used these pages as reference:
- Understanding ERC-20 token contracts, the updated version of the recommended Medium article (terrific)
- Understand the ERC-20 Token Smart Contract on Ethereum.org, mostly to reference the ERC-20 code