├── README.md └── Token.sol /README.md: -------------------------------------------------------------------------------- 1 | ## Deploy Simple ERC20 Token on Remix 2 | 3 | ### Deploy Token on Remix 4 | 5 | 1. Compile and deploy contracts on JVM to check all is working well 6 | 7 | - Copy Token.sol Solidity Code into a file in Remix rename Token.sol 8 | - Select Solidity Compiler Page 9 | - On Compiler Options dropdown select 0.8.6 version 10 | - Click "Compile Token.sol" button 11 | - Select Deploy and Run Transactions Page 12 | - Environment dropdown select JavaScript VM 13 | - Accounts dropdwon -> pick any of the accounts in dropdown 14 | - Deploy Button 15 | - Enter the parameters for deployment for (name, symbol, decimals,totalSupply) 16 | - Example paramters "TokenName", "TKT", 18, 7000 17 | - Click deploy button 18 | - Deployed Contracts 19 | - Scroll down to deployed contracts section and click on deployed contract 20 | - View buttons for all the functions you can carry out on contract e.g approve, transfer etc 21 | 22 | 1. Deploy Token to Kovan Testnet 23 | 24 | - Select Deploy and Run Transactions Page 25 | - Environment dropdown select Injected Web3 (to allow use of Metamask) 26 | - Accounts dropdwon will have first currently selected Metamask account 27 | - Get some testnet ETH, Kovan ETH into the deploying account 28 | - Copy the address from accounts 29 | - Go to [https://linkfaucet.protofire.io/kovan](https://linkfaucet.protofire.io/kovan) paste account and request some Kovan ETH 30 | - Deploy Button 31 | - Enter the parameters for deployment for (name, symbol, decimals,totalSupply) 32 | - Example paramters "TokenName", "TKT", 18, 7000000000000000000000 33 | - Click deploy button and confirm transaction on MetaMask 34 | - Deployed Contracts 35 | - Scroll down to deployed contracts section and click on deployed contract 36 | - View buttons for all the functions you can carry out on contract e.g approve, transfer etc (Deployer will have all the initial tokens) 37 | - Copy the Deployed Token address on Deployed Contracts e.g 0x5b01c8aE3185774068AF96978e1461c2A31e8A9e 38 | 39 | ### List ERC20 Token on Uniswap 40 | 41 | - Go to [Uniswap](https://app.uniswap.org/) 42 | - Click on Pool Tab 43 | - Click on More Tab and Select Create Pool 44 | - Add Liquidity 45 | - Under Select Pair leave ETH selected 46 | - Click on Select Token dropdown 47 | - Paste your deployed Token address into Search 48 | - Your deployed Token will show => Click Import 49 | - On same add Liquidity Page, select a fee e.g 0.3% fee ideal for stable pairs 50 | - Initialize Pool 51 | - On same Liquidity Page => Set the starting price for Token e.g 0.001 52 | - Set the price range 0.001 to 0.002 53 | - Deposit Amounts 54 | - Ensure you have sufficient balances for the amounts you will choose to deposit 55 | - Select amount of ETH to deposit e.g 0.001 ETH corresponding equal amount of your Token will be displayed 56 | - Click Approve Button and confirm transaction on Metamask 57 | - Once transaction finished you can click on Preview to view the added Token vs ETH liquidity pool 58 | - Click Add to finalize the adding of assets and liquidity pool creation 59 | - New Pool will display once success on your positions on page 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Token.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.6; 3 | // use latest solidity version at time of writing, need not worry about overflow and underflow 4 | 5 | /// @title ERC20 Contract 6 | 7 | contract Token { 8 | 9 | // My Variables 10 | string public name; 11 | string public symbol; 12 | uint256 public decimals; 13 | uint256 public totalSupply; 14 | 15 | // Keep track balances and allowances approved 16 | mapping(address => uint256) public balanceOf; 17 | mapping(address => mapping(address => uint256)) public allowance; 18 | 19 | // Events - fire events on state changes etc 20 | event Transfer(address indexed from, address indexed to, uint256 value); 21 | event Approval(address indexed owner, address indexed spender, uint256 value); 22 | 23 | constructor(string memory _name, string memory _symbol, uint _decimals, uint _totalSupply) { 24 | name = _name; 25 | symbol = _symbol; 26 | decimals = _decimals; 27 | totalSupply = _totalSupply; 28 | balanceOf[msg.sender] = totalSupply; 29 | } 30 | 31 | /// @notice transfer amount of tokens to an address 32 | /// @param _to receiver of token 33 | /// @param _value amount value of token to send 34 | /// @return success as true, for transfer 35 | function transfer(address _to, uint256 _value) external returns (bool success) { 36 | require(balanceOf[msg.sender] >= _value); 37 | _transfer(msg.sender, _to, _value); 38 | return true; 39 | } 40 | 41 | /// @dev internal helper transfer function with required safety checks 42 | /// @param _from, where funds coming the sender 43 | /// @param _to receiver of token 44 | /// @param _value amount value of token to send 45 | // Internal function transfer can only be called by this contract 46 | // Emit Transfer Event event 47 | function _transfer(address _from, address _to, uint256 _value) internal { 48 | // Ensure sending is to valid address! 0x0 address cane be used to burn() 49 | require(_to != address(0)); 50 | balanceOf[_from] = balanceOf[_from] - (_value); 51 | balanceOf[_to] = balanceOf[_to] + (_value); 52 | emit Transfer(_from, _to, _value); 53 | } 54 | 55 | /// @notice Approve other to spend on your behalf eg an exchange 56 | /// @param _spender allowed to spend and a max amount allowed to spend 57 | /// @param _value amount value of token to send 58 | /// @return true, success once address approved 59 | // Emit the Approval event 60 | // Allow _spender to spend up to _value on your behalf 61 | function approve(address _spender, uint256 _value) external returns (bool) { 62 | require(_spender != address(0)); 63 | allowance[msg.sender][_spender] = _value; 64 | emit Approval(msg.sender, _spender, _value); 65 | return true; 66 | } 67 | 68 | /// @notice transfer by approved person from original address of an amount within approved limit 69 | /// @param _from, address sending to and the amount to send 70 | /// @param _to receiver of token 71 | /// @param _value amount value of token to send 72 | /// @dev internal helper transfer function with required safety checks 73 | /// @return true, success once transfered from original account 74 | // Allow _spender to spend up to _value on your behalf 75 | function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { 76 | require(_value <= balanceOf[_from]); 77 | require(_value <= allowance[_from][msg.sender]); 78 | allowance[_from][msg.sender] = allowance[_from][msg.sender] - (_value); 79 | _transfer(_from, _to, _value); 80 | return true; 81 | } 82 | 83 | } 84 | 85 | --------------------------------------------------------------------------------