/helloTokenSwap

Primary LanguageSolidityMIT LicenseMIT

Hello Token Swap

This repository contains Solidity-based smart contracts for EVM-compatible networks such as Ethereum. These smart contracts illustrate the swapping of two ERC20 token contracts.

For instance, USDT to EURO.

Execution Flow

  1. First deploy the EURO.sol & USDT.sol contract with 1000 tokens to be minted at initialization.
  2. Copy address of both contracts and replace the following variables insdie the TokenSwap.sol contract
    IERC20 public USDT = IERC20(0x5e17b14ADd6c386305A32928F985b29bbA34Eff5);
    IERC20 public EURO = IERC20(0x3328358128832A260C76A4141e19E2A943CD4B6D);
  3. Next deploy the TokenSwap contract.
  4. Call the mint function in both EURO & USDT contract, by passing the TokenSwap contract adress and 1000 mint count.
  5. The token swap has two steps that needs to do for tokens to be swapped. Let see in the case of USDT to EURO
    1. First call the approveSwap in the USDT contract by passing TokenSwap contract adress and 10 tokens for swap.
    2. Then call the swapToEURO in the TokenSwap contract and by passing in the required amount of swap we approved previously which is 10 tokens.
  6. In case of EURO to USDT
    1. First call the approveSwap in the EURO contract by passing TokenSwap contract adress and 10 tokens for swap.
    2. Then call the swapToUSDT in the TokenSwap contract and by passing in the required amount of swap we approved previously which is 10 tokens.