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.
- First deploy the EURO.sol & USDT.sol contract with 1000 tokens to be minted at initialization.
- Copy address of both contracts and replace the following variables insdie the TokenSwap.sol contract
Line 7 in 56e066e
Line 8 in 56e066e
- Next deploy the TokenSwap contract.
- Call the mint function in both EURO & USDT contract, by passing the TokenSwap contract adress and 1000 mint count.
- The token swap has two steps that needs to do for tokens to be swapped. Let see in the case of USDT to EURO
- First call the approveSwap in the USDT contract by passing TokenSwap contract adress and 10 tokens for swap.
- Then call the swapToEURO in the TokenSwap contract and by passing in the required amount of swap we approved previously which is 10 tokens.
- In case of EURO to USDT
- First call the approveSwap in the EURO contract by passing TokenSwap contract adress and 10 tokens for swap.
- Then call the swapToUSDT in the TokenSwap contract and by passing in the required amount of swap we approved previously which is 10 tokens.