Before you go, check out these stories!

0
Hackernoon logoCreate your own Ethereum Token. by@Nico_Vergauwen

Create your own Ethereum Token.

Author profile picture

@Nico_VergauwenNico Vergauwen

We are all familiar with ICO’s (Initial coin offering) by now. Many projects rake in millions of $ from investors with the promise of a revolutionary technology through smart contracts that will change the world.

Quite often there is only that, a promise, along with a white paper and a website and the MVP will be developed after the crowdsale. At this stage (and many projects may never get past this stage) the ‘revolutionary’ smart contracts all look somewhat similar and offer no functionality but a crowdsale.

In this article we’ll demonstrate how easy it is to actually make your own ERC20 token for the Ethereum blockchain. Make sure to check out our dApp tutorial as well.

(This article is for educational purposes only)

Step 1: The ERC20 Interface

In Solidity, the programming language for Ethereum, an interface is a piece of reusable code that defines constraints for functions and events, without implementing the function itself. A contract with the ERC20 interface must have implemented all functions defined in the interface.

Luckily we do not have to write all of this code ourselves and we can just copy it from the following repository: https://github.com/OpenZeppelin/zeppelin-solidity/tree/master/contracts/token

To get started open https://remix.ethereum.org and make two files: SafeMath.sol and ERC20.sol paste in the code below into each of the respective files.

Step 2: Implementing our functions

Great work, or building blocks are almost set. Now we have to implement the functions we have defined in our interface. For this we will combine BasicToken.sol and StandardToken.sol from OpenZeppelin into one file called StandardToken.sol .

Here’s a high level overview of what these functions do:

balanceOf : returns the token balance of an Ethereum address.

transfer : transfers an amount to an address of our choosing.

approve : sets an amount of tokens a specified address is allowed to spend on our behalf

allowance : check how much an address is allowed to spend on our behalf

transferFrom : specify an address to transfer from if we are allowed by that address to spend some tokens.

event Transfer and event Approval will log an output event onto the blockchain.

Step 3: Add your own touch

Congragulations! That was the hardest part. Now all there’s left to do is specify a name, symbol and supply for our token.

Because we tweaked things a little bit we do not have to actually code this! We can just enter the parameters we want when creating the contract in remix. Next to the create button enter a name, symbol, # decimals and total supply in that order (see example below) and press create.

Example

Well done ! You have succesfuly created your first token. Now you can test the functions by sending tokens to the addresses you’ll find in the dropdown menu next to ‘account’ in remix.

You can also deploy this to one of the test networks if you install Metamask.

The full gist can be found here: https://gist.github.com/anonymous/9eabd0015ca7dd431992a522aa8c51cd

Make sure to check out part 2 !

If you enjoyed this article please leave a tip : 
BTC — 
1DNKXrLfesJ5iN8nbYzbNUejQcshoHCcVV
ETH — 
0x6d31cb338b5590adafec46462a1b095ebdc37d50
LTC — 
LLC8PWSeDMiH5GLDgVZNq361Lm6iaQNDnj

Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!