Difference between revisions of "How to create your own Ethereum ERC20 token"

From CoinWiki
Jump to: navigation, search
Line 19: Line 19:
 
* You'll need to change the values in lines 119-123 to that of your tokens as seen here.
 
* You'll need to change the values in lines 119-123 to that of your tokens as seen here.
  
[[File: erc20-function.png|left|thumb]]
+
 
 +
[[File: erc20-function.png|center]]
 +
 
  
 
* Things to keep in mind. There is a correlation between the decimals you set and your tokens supply. For example, if you want 1,000 tokens and you have your decimal set at 5, you will need to set the total supply to be 100000000 (5 zeros added to the amount).
 
* Things to keep in mind. There is a correlation between the decimals you set and your tokens supply. For example, if you want 1,000 tokens and you have your decimal set at 5, you will need to set the total supply to be 100000000 (5 zeros added to the amount).
Line 25: Line 27:
 
* The next step is to test your token on the test net. If don't have it already, you will need to download [https://metamask.io MetaMask]]. Log in and set up MetaMask so that you are in the Ropsten Test Network as shown.
 
* The next step is to test your token on the test net. If don't have it already, you will need to download [https://metamask.io MetaMask]]. Log in and set up MetaMask so that you are in the Ropsten Test Network as shown.
  
[[File: erc20-meta1.png|left|thumb]]
+
 
 +
[[File: erc20-meta1.png|center]]
 +
 
  
 
* Next head over to [https://remix.ethereum.org Remix Solidity IDE]]. It is where we will be publishing our Smart Contract to the blockchain. Copy and paste your code into Remix and you should see something like this.
 
* Next head over to [https://remix.ethereum.org Remix Solidity IDE]]. It is where we will be publishing our Smart Contract to the blockchain. Copy and paste your code into Remix and you should see something like this.
  
[[File: erc20-remix.png|left|thumb]]
+
 
 +
[[File: erc20-remix.png|center]]
 +
 
  
 
* Click on the 'Run' tab and hit 'Deploy' under 'ERC20Token'. A MetaMask tab will pop up and you will have to hit 'Submit' to pay for the transaction. Remember since you are using test Ether so it won't cost you any real money.
 
* Click on the 'Run' tab and hit 'Deploy' under 'ERC20Token'. A MetaMask tab will pop up and you will have to hit 'Submit' to pay for the transaction. Remember since you are using test Ether so it won't cost you any real money.
  
[[File: erc20-remix-run.png|left|thumb]]
+
 
 +
[[File: erc20-remix-run.png|center]]
 +
 
  
 
* If you go into MetaMask under the sent tab and press your 'Contract Deployment' you will be brought to a page that looks like this that displays your transaction information.  
 
* If you go into MetaMask under the sent tab and press your 'Contract Deployment' you will be brought to a page that looks like this that displays your transaction information.  
  
[[File: erc20-remix-success.png|left|thumb]]
+
 
 +
[[File: erc20-remix-success.png|center]]
 +
 
  
 
* To add your token to MetaMask, copy your contract code and go into MetaMask and click on the 'Add Token' button and paste in your contract address. Your token symbol and decimals of precision should appear automatically. Press the 'add' button and your token will be added to your list of tokens.
 
* To add your token to MetaMask, copy your contract code and go into MetaMask and click on the 'Add Token' button and paste in your contract address. Your token symbol and decimals of precision should appear automatically. Press the 'add' button and your token will be added to your list of tokens.
  
[[File: erc20-metamask-add.png|left|thumb]]
+
 
 +
[[File: erc20-metamask-add.png|center]]
 +
 
 +
 
 +
* To verify your source code, click on your contract address in ropsten.etherscan.io and you will be brought to a new page where you will need to click on the 'Code' tab and then press 'Verify And Publish'.
 +
 
 +
 
 +
[[File: erc20-remix-verify.png|center]]
 +
 
 +
 
 +
* On the verification page you will need your contract address, contract name, compiler version and paste in your contract code. Next scroll to the bottom of the page and press 'Verify and Publish'. It generally takes about 30 seconds to get your results.
 +
 
 +
 
 +
[[File: erc20-remix-verified.png|center]]
 +
 
 +
 
 +
* Congrats! Your smart contract is verified!
 +
* To get your token on the main net, all you need to do is repeat the process with MetaMask connected to the MainNet. I put mine on the main net for about $5 in Ether.

Revision as of 18:07, 23 March 2019

An ERC20 token is a protocol for proposing improvements to the Ethereum (ETH) network. The token can have value as well as be sent and received just like any other cryptocurrency.

The first step to creating a ERC20 token is to decide what you want the token to be. You'll need to choose the following:

  • A name for your token
  • Your token's symbol (generally 3-4 characters long)
  • The number of tokens you will have in circulation
  • How many decimal places your token will have (Most tokens have 18 decimal places but you can have any number you like)

For my token KiwiCoin, I chose: - KiwiCoin - KIWI - 180000000 - ​18

  • The next step is to code your ERC20 contract. You can copy this contract code below courtesy of TokenFactory and paste it into your favorite code editor. I use Atom.

  • You'll need to change the values in lines 119-123 to that of your tokens as seen here.


Error creating thumbnail: Unable to save thumbnail to destination


  • Things to keep in mind. There is a correlation between the decimals you set and your tokens supply. For example, if you want 1,000 tokens and you have your decimal set at 5, you will need to set the total supply to be 100000000 (5 zeros added to the amount).
  • The next step is to test your token on the test net. If don't have it already, you will need to download MetaMask]. Log in and set up MetaMask so that you are in the Ropsten Test Network as shown.


Error creating thumbnail: Unable to save thumbnail to destination


  • Next head over to Remix Solidity IDE]. It is where we will be publishing our Smart Contract to the blockchain. Copy and paste your code into Remix and you should see something like this.


Error creating thumbnail: Unable to save thumbnail to destination


  • Click on the 'Run' tab and hit 'Deploy' under 'ERC20Token'. A MetaMask tab will pop up and you will have to hit 'Submit' to pay for the transaction. Remember since you are using test Ether so it won't cost you any real money.


Error creating thumbnail: Unable to save thumbnail to destination


  • If you go into MetaMask under the sent tab and press your 'Contract Deployment' you will be brought to a page that looks like this that displays your transaction information.


Error creating thumbnail: Unable to save thumbnail to destination


  • To add your token to MetaMask, copy your contract code and go into MetaMask and click on the 'Add Token' button and paste in your contract address. Your token symbol and decimals of precision should appear automatically. Press the 'add' button and your token will be added to your list of tokens.


Error creating thumbnail: Unable to save thumbnail to destination


  • To verify your source code, click on your contract address in ropsten.etherscan.io and you will be brought to a new page where you will need to click on the 'Code' tab and then press 'Verify And Publish'.


Error creating thumbnail: Unable to save thumbnail to destination


  • On the verification page you will need your contract address, contract name, compiler version and paste in your contract code. Next scroll to the bottom of the page and press 'Verify and Publish'. It generally takes about 30 seconds to get your results.


Error creating thumbnail: Unable to save thumbnail to destination


  • Congrats! Your smart contract is verified!
  • To get your token on the main net, all you need to do is repeat the process with MetaMask connected to the MainNet. I put mine on the main net for about $5 in Ether.