Learn Everything About ERC20 Tokens
By Pankaj Verma on ALTCOIN MAGAZINE
What Are Smart Contracts?
Smart contracts help you exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman.
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. The code controls the execution, and transactions are trackable and irreversible.
What Is An ERC20 Token?
ERC-20 is a technical standard used for smart contracts on the Ethereum blockchain for implementing tokens. The majority of tokens issued on the Ethereum blockchain are ERC-20.
In ‘ERC20’, ERC stands for Ethereum Request For Comments and 20 stands for a unique ID number to distinguish this standard from others.
Similar to the fact that we have an HTTP protocol for the internet, we have a standard protocol for tokens to be issued on Ethereum i.e. ERC20.
totalSupply()
Although the supply could easily be fixed, this function returns the total amount of the token.
balanceOf()
This function allows a smart contract to store and return the balance of the provided address. The function accepts an address as a parameter, so it should be known that the balance of any address is public.
approve()
When calling this function, the owner of the contract authorizes or approves, the given address to withdraw instances of the token from the owner’s address.
transfer()
This function lets the owner of the contract send a given amount of the token to another address just like cryptocurrency transactions.
transferFrom()
This function allows a smart contract to automate the transfer process and send a given amount of the token on behalf of the owner.