Tutorial: mint and trade your own ERC-20 tokens

Deploy an ERC-20 contract and trade the tokens on Uniswap on Oasis Ethereum ParaTime!

This tutorial will walk you through the following tasks.

  1. How to issue an ERC20 token on Oasis Ethereum ParaTime. You will get 100 to 500 ROSE after completing this step.

  2. Build a liquidity pool on Uniswap, trade your ERC20 tokens and OETH, you will get 400 ROSE.

Deploy the ERC20 smart contract

Oasis Ethereum ParaTime is fully compatible with Ethereum, so ERC20 contracts written in solidity can be deployed directly to Oasis Ethereum ParaTime without any changes.

This part can still be developed using the development tool, BUIDL, that has been configured for the development environment.

Step 1 Set up MetaMask

:warning: Warning: Pasting the private key of an account with a lot of value (i.e. a holding account) is not recommended whatsoever. Instead, please only transfer a tiny amount of value to a new one-off development account address and only use this new development account when writing and deploying your contracts. After all, you only need enough value to pay for gas; nothing else. Keep your holding account safe by never sharing its private keys.

It is recommended that the third challenge to be completed with MetaMask wallet because our newly issued ERC20 token is under the created address, which is easier.

Open MetaMask, and select custom RPC. Enter the network name and add the RPC link of Oasis Ethereum: https://rpc.oasiseth.org:8545, and make sure that MetaMask is in the Oasis Ethereum environment.

Then deposit 1 OETH to this MetaMask account from the OETH developer faucet.

Step 2 Import the MetaMask account address into the BUIDL Account

Click to open “account”, select Import, import the MetaMask private key just set up into the BUIDL account, and prepare for the deployment of ERC20 contracts to pay gas fees.

Step 3 compile and deploy the smart contract

You can load the web-based IDE by going to the link below. There is no software to download!

Select the ERC-20 sample project from the menu.

Tips: Now you can choose the solidity language version on BUIDL.

The smart contract source code is as follows.

contract TestToken is PausableToken {

  string public name = "Test Token";
  string public symbol = "TTT";
  uint public decimals = 10;
  uint public totalSupply = 100000000000000000000;

  constructor () public {
    balances[msg.sender] = totalSupply;
  }
}

At the end of the contract code, contract TestToken is the specifics of ERC20 tokens. Here, tweak the code to customize the name of the ERC20 token to your preferences, symbol, decimal, and total supply.

Click the Compile button and select TestToken to deploy to the blockchain.

After the deployment is successful, the task of issuing ERC 20 tokens on Oasis Ethereum ParaTime is nailed. Please note that the token address here needs to be saved and used when adding tokens in MetaMask. Also, this address also needs to be submitted to the organizer when filling this form.

The next step is to complete the task for bonus rewards: building a liquidity pool for your ERC20 tokens on Uniswap, and start transactions.

Add a Liquidity pool on Uniswap

To create a liquidity pool for tokens on Uniswap, you need to work with MetaMask. Please ensure that MetaMask is connected to the beta version of the Oasis Ethereum mainnet.

Step 1 Add the ERC20 token you just issued in MetaMask

Under the current account, slide to the end, click Add Token—>Custom Token, and fill the token address just saved before. The decimal **and symbol of your token will be automatically added.

Step 2 Create Exchange for your Token

Open Website: https://uniswap.oasiseth.org/swap, go to Pool.

https://uniswap.oasiseth.org/swap

Click Add Liquidity, select Create Exchange in the pop-up option box, and then add the token address just saved. Then click Create Exchange and click Confirm to pay the gas fee.

Step 3 Create a liquidity pool

Return to the Pool page, click Add Liquidity, and select Add Liquidity in the opened options. Select the token issued by yourself at the deposit place below and click Unlock.

After clicking Unlock, MetaMask will automatically launch a transaction prompt. Here, MetaMask is authorized to manage the previous MFT of Uniswap.

After the word “unlock” disappears, you can set any exchange ratio between the token you issued and OETH, and finally, click Add Liquidity at the bottom to generate a liquidity pool.

Step 4 Swap with OETH

Go to Swap, enter the amount of OETH you want to exchange, and Uniswap will automatically convert the amount at the ratio set immediately. Click the Swap button to trade the token you just issued with OETH in Uniswap.

Now you have minted and traded your own tokens on the Oasis Ethereum ParaTime! You can watch the YouTube video below to review the entire process.

Happy coding!

Last updated