├── README.md ├── TestToken.sol └── old └── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Issue an ERC-20 token with Remix and Metamask 2 | 3 | In this step-by-step tutorial you will learn how to issue and play with your own ERC-20 token on Ethereum. This tutorial can be completed by people with no blockchain programming experience and novice programmers. 4 | 5 | We will use [Metamask](www.metamask.com) and [Remix IDE](www.remix.ethereum.org) 6 | 7 | By the end of this tutorial you will be able to deploy standard ERC-20 Tokens! Please get your code verified and audited by a 3rd party before releasing any token to the public. 8 | 9 | ### Preparation 10 | 11 | Download and Install [MetaMask](https://metamask.io) 12 | 13 | - Install on Chrome, Firefox or Brave Browser 14 | 15 | - Create a new account and save your 12 word mnemonic 16 | 17 | - Select a test network. The Ropsten Network should work fine. 18 | 19 | Get Some Testnet Ether 20 | 21 | - Click "Buy" or "Deposit" on Metamask or go to the [Metamask Faucet](https://faucet.metamask.io/) 22 | 23 | - Hit "Send Me Ether". It should not take long (10-20 seconds) 24 | 25 | - Double check Ether was received by hitting the MetaMask Icon 26 | 27 | 28 | ### Find Smart Contract Code Implentation 29 | 30 | Find Source Code for a Standard ERC-20 Smart Contract. You want a well tested open source implementation such as the official Consensys or Open Zeppelin implementation. Select one of the following two options: 31 | 32 | - Navigate to the [Consensys Token Repository](https://github.com/ConsenSys/Tokens). 33 | 34 | - Navigate to the [OpenZeppelin Smart Contract Repository] (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts). Find 35 | 36 | These repositories contain the solidity code you need to deploy your token. Consensys implemntation is easier to deploy, but the OpenZeppelin implementation is more widely used in practice. 37 | 38 | ### Build your Solidity Smart Contract in Remix 39 | - Launch [Remix](http://remix.ethereum.org) 40 | 41 | - Enable the "Solidity Compiler" and "Deploy & Run Transactions" Tabs. Find them using the plugin manager on the left. 42 | 43 | - Copy the .sol files you need into remix. To create a new .sol file, click the "+" button in the top left. Either copy the code directly from github, or clone the repository and open the local files. 44 | 45 | - For the Consensys implementation get 46 | - EIP20interface.sol 47 | - EIP20.sol 48 | 49 | - For the OpenZeppelin implementation get 50 | - ERC20.sol 51 | - IERC20.sol 52 | - SafeMath.sol 53 | - Context.sol 54 | - ERC20Detailed.sol. 55 | You will have to locate them in different folders. 56 | 57 | - Open the base contract. For Consensys it's EIP20.sol. For OpenZeppelin it's ERC20Detailed.sol 58 | 59 | - For the OpenZeppelin contract, import and inherit ERC20.sol instead of IERC20.sol. 60 | ``` 61 | import "./ERC20.sol" 62 | contract ERC20Detailed is ERC20.sol 63 | ``` 64 | 65 | - Try compiling the contract by pressing ctrl-s or pressing the compile button on the compile tab. You will notice a couple errors. 66 | 67 | - Make sure all import references work. For example import "./SafeMath.sol" 68 | 69 | - Make sure the compiler version is the same as the contract version 70 | 71 | - Ensure the contract compiles correctly 72 | 73 | - Think of a cool name for your token and rename your base file YourTokenName.sol 74 | 75 | - rename your contract 76 | 77 | ``` 78 | contract YourTokenName{ 79 | ``` 80 | 81 | - For the Consensys contract, rename your constructor function from EIP to yourTokenName 82 | 83 | ``` 84 | function YourTokenName( 85 | ``` 86 | 87 | 88 | ### Customize your Smart Contract 89 | Now you can personalize the token according to your preferences 90 | 91 | - Decide on a symbol to go with your name, e.g. YTN for YourTokenName 92 | 93 | - Decide on the number of decimal places your token will have. 94 | 95 | - Decide on your Token Supply, or how many tokens you want to exist in total. 96 | 97 | - NOTE: Ethereum only deals in integers only and DOES NOT recognize fractions. 1000 integers are required to represent 1 token with 3 decimal places. Therefore add an extra 0 to your token supply for every decimal place in your token. 98 | 99 | - Click on the Run tab in remix 100 | 101 | - Next to the Deploy Button, Enter your InitialAmount, TokenName, Decimals, TokenSymbol as parameters like so: 1000000,"YourTokenName",3,"YTN". Don't forget quotes for the strings. 102 | 103 | - Alternatively you can directly input values into your Smart Contract code. Just remember to remove the code that sets the variables inside the constructor function 104 | 105 | 106 | ### Compiling and Deploying 107 | 108 | - Check for errors on remix. Yellow warnings are ok. Red warnings must be fixed before the next step. 109 | 110 | - Make sure you are still on the Run tab 111 | 112 | - Select YourTokenName in the drop down menu 113 | 114 | - Select "Injected Web3" for your environment 115 | 116 | - Click Deploy 117 | 118 | - Approve the transaction on metamask. You may need to enable pop ups on your browser 119 | 120 | - Wait for the transaction to mine! Check for confirmation on [EtherScan](https://ropsten.etherscan.io/). You can click on your latest transaction in metamask. 121 | 122 | - After the transaction has mined, click the contract address and copy it 123 | 124 | - Paste it into the Tokens sectionin Metamask 125 | 126 | **You have now issued your first Token. Great Work! This is just the tip of the iceberg.** 127 | 128 | ## Notes 129 | 130 | - Gas price should auto update. For live Eth use https://ethgasstation.info/ 131 | 132 | ## Optional - Register and Verify 133 | 134 | Now we are going to register this contract. To do this: 135 | 136 | - Using Etherscan: In the Overview Tab → Click on the Contract Address 137 | 138 | - Go to the Contract Code Tab → Click Verify and Publish 139 | 140 | ### Words of Wisdom: Get it right once or get it wrong forever. 141 | 142 | - Be sure that the contract address field corresponds to the contract address that you have just deployed. 143 | *Remember contract address is different to your public key* 144 | 145 | - The contract name has to match the one in the code, in my case is this: **WaterlooCoin**. This will be on *Line 102* in your code 146 | 147 | - Enter the correct compiler version. At the time of writing, this is ```Compiler: 0.4.24+commit.e67f0147``` 148 | *In future builds, this can be found by hitting the Details tab under Compile, and selecting the Compiler dropdown under MetaData.* 149 | 150 | - On Optimisation, choose **No** (We haven’t enable it before). 151 | 152 | - On ENTER THE SOLIDITY CONTRACT CODE BELOW, copy the whole code from Remix, and paste in that area. 153 | 154 | - Leave the other fields in blank and click on Verify and Publish. 155 | 156 | **If you get a success! It worked.** 157 | 158 | To confirm that it worked, go to https://ropsten.etherscan.io/ and look up your metamask address. Hit the **View Tokens** dropdown to see if you tokens are in there. 159 | 160 | ## Sending Tokens 161 | 162 | Send some to your neighbours: 163 | 164 | - In Metamask Open the menu and click "Add Tokens" 165 | 166 | - Click Add Custom Token and Input your Contract Address. Your token details should appear automatically 167 | 168 | - You should now see your token balance. Try sending some tokens to your friend's address Check Etherscan for progress 169 | 170 | - Your friend can then enter your contract info and code to view your tokens in their wallet! 171 | -------------------------------------------------------------------------------- /TestToken.sol: -------------------------------------------------------------------------------- 1 | // contracts/GLDToken.sol 2 | // SPDX-License-Identifier: MIT 3 | pragma solidity ^0.8.7; 4 | 5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 6 | 7 | contract Testcoin is ERC20 { 8 | constructor() ERC20("Testcoin", "TEST") { 9 | _mint(msg.sender, 21e27); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /old/README.md: -------------------------------------------------------------------------------- 1 | # Issue an ERC-20 token with Remix and Metamask 2 | 3 | In this step-by-step tutorial you will learn how to issue and play with your own ERC-20 token on Ethereum. This tutorial can be completed by people with no blockchain programming experience and novice programmers. 4 | 5 | We will use [Metamask](www.metamask.com) and [Remix IDE](www.remix.ethereum.org) 6 | 7 | By the end of this tutorial you will be able to deploy standard ERC-20 Tokens! Please get your code verified and audited by a 3rd party before releasing any token to the public. 8 | 9 | ### Preparation 10 | 11 | Download and Install [MetaMask](https://metamask.io) 12 | 13 | - Install on Chrome, Firefox or Brave Browser 14 | 15 | - Create a new account and save your 12 word mnemonic 16 | 17 | - Select a test network. The Ropsten Network should work fine. 18 | 19 | Get Some Testnet Ether 20 | 21 | - Click "Buy" or "Deposit" on Metamask or go to the [Metamask Faucet](https://faucet.metamask.io/) 22 | 23 | - Hit "Send Me Ether". It should not take long (10-20 seconds) 24 | 25 | - Double check Ether was received by hitting the MetaMask Icon 26 | 27 | 28 | ### Find Smart Contract Code Implentation 29 | 30 | Find Source Code for a Standard ERC-20 Smart Contract. You want a well tested open source implementation such as the official Consensys or Open Zeppelin implementation. Select one of the following two options: 31 | 32 | - Navigate to the [Consensys Token Repository](https://github.com/ConsenSys/Tokens). 33 | 34 | - Navigate to the [OpenZeppelin Smart Contract Repository] (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts). Find 35 | 36 | These repositories contain the solidity code you need to deploy your token. Consensys implemntation is easier to deploy, but the OpenZeppelin implementation is more widely used in practice. 37 | 38 | ### Build your Solidity Smart Contract in Remix 39 | - Launch [Remix](http://remix.ethereum.org) 40 | 41 | - Enable the "Solidity Compiler" and "Deploy & Run Transactions" Tabs. Find them using the plugin manager on the left. 42 | 43 | - Copy the .sol files you need into remix. To create a new .sol file, click the "+" button in the top left. Either copy the code directly from github, or clone the repository and open the local files. 44 | 45 | - For the Consensys implementation get 46 | - EIP20interface.sol 47 | - EIP20.sol 48 | 49 | - For the OpenZeppelin implementation get 50 | - ERC20.sol 51 | - IERC20.sol 52 | - SafeMath.sol 53 | - Context.sol 54 | - ERC20Detailed.sol. 55 | You will have to locate them in different folders. 56 | 57 | - Open the base contract. For Consensys it's EIP20.sol. For OpenZeppelin it's ERC20Detailed.sol 58 | 59 | - For the OpenZeppelin contract, import and inherit ERC20.sol instead of IERC20.sol. 60 | ``` 61 | import "./ERC20.sol" 62 | contract ERC20Detailed is ERC20.sol 63 | ``` 64 | 65 | - Try compiling the contract by pressing ctrl-s or pressing the compile button on the compile tab. You will notice a couple errors. 66 | 67 | - Make sure all import references work. For example import "./SafeMath.sol" 68 | 69 | - Make sure the compiler version is the same as the contract version 70 | 71 | - Ensure the contract compiles correctly 72 | 73 | - Think of a cool name for your token and rename your base file YourTokenName.sol 74 | 75 | - rename your contract 76 | 77 | ``` 78 | contract YourTokenName{ 79 | ``` 80 | 81 | - For the Consensys contract, rename your constructor function from EIP to yourTokenName 82 | 83 | ``` 84 | function YourTokenName( 85 | ``` 86 | 87 | 88 | ### Customize your Smart Contract 89 | Now you can personalize the token according to your preferences 90 | 91 | - Decide on a symbol to go with your name, e.g. YTN for YourTokenName 92 | 93 | - Decide on the number of decimal places your token will have. 94 | 95 | - Decide on your Token Supply, or how many tokens you want to exist in total. 96 | 97 | - NOTE: Ethereum only deals in integers only and DOES NOT recognize fractions. 1000 integers are required to represent 1 token with 3 decimal places. Therefore add an extra 0 to your token supply for every decimal place in your token. 98 | 99 | - Click on the Run tab in remix 100 | 101 | - Next to the Deploy Button, Enter your InitialAmount, TokenName, Decimals, TokenSymbol as parameters like so: 1000000,"YourTokenName",3,"YTN". Don't forget quotes for the strings. 102 | 103 | - Alternatively you can directly input values into your Smart Contract code. Just remember to remove the code that sets the variables inside the constructor function 104 | 105 | 106 | ### Compiling and Deploying 107 | 108 | - Check for errors on remix. Yellow warnings are ok. Red warnings must be fixed before the next step. 109 | 110 | - Make sure you are still on the Run tab 111 | 112 | - Delect YourTokenName in the drop down menu 113 | 114 | - Click Deploy 115 | 116 | - Approve the transaction on metamask. You may need to enable pop ups on your browser 117 | 118 | - Wait for the transaction to mine! Check for confirmation on [EtherScan](https://ropsten.etherscan.io/). You can click on your latest transaction in metamask. 119 | 120 | - After the transaction has mined, click the contract address and copy it 121 | 122 | - Paste it into the Tokens sectionin Metamask 123 | 124 | **You have now issued your first Token. Great Work! This is just the tip of the iceberg.** 125 | 126 | ## Notes 127 | 128 | - Gas price should auto update. For live Eth use https://ethgasstation.info/ 129 | 130 | ## Optional - Register and Verify 131 | 132 | Now we are going to register this contract. To do this: 133 | 134 | - Using Etherscan: In the Overview Tab → Click on the Contract Address 135 | 136 | - Go to the Contract Code Tab → Click Verify and Publish 137 | 138 | ### Words of Wisdom: Get it right once or get it wrong forever. 139 | 140 | - Be sure that the contract address field corresponds to the contract address that you have just deployed. 141 | *Remember contract address is different to your public key* 142 | 143 | - The contract name has to match the one in the code, in my case is this: **WaterlooCoin**. This will be on *Line 102* in your code 144 | 145 | - Enter the correct compiler version. At the time of writing, this is ```Compiler: 0.4.24+commit.e67f0147``` 146 | *In future builds, this can be found by hitting the Details tab under Compile, and selecting the Compiler dropdown under MetaData.* 147 | 148 | - On Optimisation, choose **No** (We haven’t enable it before). 149 | 150 | - On ENTER THE SOLIDITY CONTRACT CODE BELOW, copy the whole code from Remix, and paste in that area. 151 | 152 | - Leave the other fields in blank and click on Verify and Publish. 153 | 154 | **If you get a success! It worked.** 155 | 156 | To confirm that it worked, go to https://ropsten.etherscan.io/ and look up your metamask address. Hit the **View Tokens** dropdown to see if you tokens are in there. 157 | 158 | ## Optional - Sending Tokens 159 | 160 | Send some to your neighbours: 161 | 162 | - Use [MyEtherWallet](https://www.myetherwallet.com/) to get tokens out of your MetaMask account. 163 | 164 | - Hit *Send Ether & Tokens* 165 | 166 | - Select *MetaMask Access* from the dropdown 167 | 168 | - Confirm 169 | 170 | - Add your Contract Address to the Token Balances area to confirm you have the tokens. 171 | 172 | - Change to your created token 173 | 174 | - Enter your friend’s public address 175 | 176 | - Change gas limit to 150,000 for faster transfer 177 | 178 | - Send! Check etherscan for progress 179 | 180 | - Your friend can then enter your contract info and code to view your tokens in their wallet! 181 | --------------------------------------------------------------------------------