erc20-token-contract.png

What is ERC20 Token Contract in Ethereum

16/December/2019
Ethereum blockchain has been a hot favorite of tech enthusiasts since its launch. It was the first blockchain technology that introduced smart contract plugins. It pushes the blockchain tech further forward. The ethereum token contract got a wide appreciation in the finance and banking sector, because various token standards like erc20,erc721 allowed the business firms to process micropayments without moments of delay. The erc20 token standard is one of the most used token standards in ethereum protocol. Because it allows an end-user to create and transfer the token in a more simplified way. The ERC20 token standard is given below:

function totalSupply() public view returns (uint256);
*The totalSupply() function is used to find the no of tokens running through the networks. It also returns the predefined supply from the contract

function balanceOf(address tokenOwner) public view returns (uint);
*The balanceOf() function is used to find the available balance token carried by each individual owner

function allowance(address tokenOwner, address spender)public view returns(uint);
*The allowance() function is used to check the allowed token balance approved from another user

function transfer(address to, uint tokens) public returns (bool);
*The transfer function is used to transfer token between two users

function approve(address spender, uint tokens)  public returns (bool);
*The approve function is used to assign a spender account for token instead of the original owner

function transferFrom(address from, address to, uint tokens)public returns (bool);
*The transferFrom() is used to spend the allowed token by the spender account

The above-predefined functions are used in the solidity enabled smart contract which can be used to generate and transfer erc20 tokens. The contract given below is a combination of three contracts and one safe math library.

erc20 token contract in ethereum


The above safe math library is used for basic arithmetic operations. It consists of mainly four functions which are used for addition, subtraction, multiplication, and division. It is primarily used for token transfer use cases. Each of those functions is called from the main GMT contract in order to do the math more precisely.

erc20 token contract in ethereum


The ERC20 Interface contract is used for following the protocol for ethereum token, this contract is inherited by the GMT main contract in order to implement the ERC20 token standard.

erc20 token contract in ethereum


The owned contract can only be invoked by the owned address, it is used to transfer the ownership, freeze the ICO as well as to set the rate of token.

erc20 token contract in ethereum

erc20 token contract in ethereum

erc20 token contract in ethereum


The GMT contract is the main contract that inherits the other two contracts(owned, ERC20 interface), it uses the function defined in the other two contracts.

Comments

0

Leave a comment