Develop your ERC-20 Token — explained!

Hargobind Gupta
Blockchain Development Agency
3 min readJan 9, 2019

ERC 20 Tokens are creating a rage in the cryptocurrency sector and you wouldn’t want to be left behind, would you? Anyone who is keen to know the functionality involved in an ERC-20 token creation and deployment is welcomed. Let’s get started.

What is an ERC-20 Token?

Ethereum Request For Comments 20(ERC 20) is a protocol standard that defines certain rules and standards for issuing tokens on Ethereum’s network.

A Token developed on Ethereum Blockchain is said to be an ERC-20 compliant only if it includes the basic functions defined by the protocol in its smart contract. The functions defined in the protocol are :

// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

The Ethereum community created this protocol so that a token can be shared, exchanged for other tokens, or transferred to a crypto-wallet as effortlessly as possible.

Things required to develop a Token.

Proficiency in Solidity, the official language to write smart-contracts on Ethereum Blockchain. The only hackable module in your Blockchain Project is your smart contract, So one should give utmost importance to its development as we do at traceblocks.

Also this

  1. Ethereum Address (Ropsten Network)
  2. Some Ethereum (Ropsten Network)
  3. A text editor (I.e. Sublime / Atom)
  4. Solidity contract

Let’s jump into the code.

The Ethereum community created these standards with three optional rules, and six mandatory.

Optional

  • Token Name
  • Symbol
  • Decimal (up to 18)

Mandatory

  • totalSupply: identifies the total number of ERC-20 tokens created.
  • balanceOf: it returns the number of tokens a given address has in its account.
  • transfer: allows a certain number of tokens to be transferred from the total supply to a user account.
  • transferFrom: is the function that allows a user to transfer tokens to another user.
  • approve : checks a transaction against the total supply of tokens.
  • allowance: function checks the balance of the user’s account and will cancel the transaction if there are insufficient tokens.

A sample smart contract implementing all the protocol is defined here. The comments will guide you when you are inside.

If you find this useful, please share it with your crypto freaks in your network.

If you don’t want to take the burden of doing all this, reach out to me at hargobindgupta@gmail.com

--

--

Hargobind Gupta
Blockchain Development Agency

An aspiring entrepreneur making way through the ever evolving and advanced world of technology. An early adopter of Blockchain Revolution.