Metamask: Etherscan SwapExactTokensForETH on Rinkby

Here is an article outline:

Testing the exact ETH exchange tokens on the Rink via a Uniswap smart contract

As part of my ongoing testing and learning process, I wanted to demonstrate how to use the Etherscan platform to test different smart contract interactions. Today I will be using the Rink by Uniswap smart contract to exchange Link for WETH.

Step 1: Approving a Uniswap smart contract

Metamask: Etherscan SwapExactTokensForETH on Rinkby

First, I had to approve the Rink by Uniswap smart contract on Etherscan. To do this, I logged into my Etherscan account and went to the Uniswap contract page. Then I clicked the “Approve” button next to the contract name.

After the contract was approved, a transaction was executed, which updated the contract balance accordingly.

Step 2: Calling the Swap Exact Tokens For ETH Function

Next, I wanted to call the swapExactTokensForETH function in my Uniswap smart contract. This feature allows me to swap a specific amount of tokens (in this case Link) for a specific amount of another token (WETH). To do this, I used the following Etherscan transaction:

0x... contractAddress... 0xAaBcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYzZz...

Here’s a breakdown of what each part of the transaction means:

  • contractAddress: Address of the My Rink by Uniswap smart contract
  • 0xAaBcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYzZz...: a random 36-byte address (which I generated using a crypto wallet or a tool like MetaMask)

Die swapExactTokensForETH function accepts three parameters: the value of the link to exchange for WETH, the price of WETH in ETH per link and the deadline for the trade. In this case, I set all three parameters to 1.

Note: This trade assumes you have MetaMask installed on your Ethereum account and are logged in to your wallet. If you are not using MetaMask, you will need to install it before making these trades.

After creating the trade, I made sure to run it through a tool like Remix or Truffle to execute it in a local network environment (as I do not have access to an on-chain Ethereum testnet).

Now I am waiting for the trade to be processed and the trade results to be available on Etherscan. If all goes well, my Rink by Uniswap smart contract will be able to swap Link for WETH without any problems!