简体   繁体   中英

how to swap Token for ETH with swapExactTokensForETH() using UniswapV2Router02 Contract

i'm traying to swap some DAI for ETH on the Ropsten Network using the UniswapV2Router02 on Etherscan (Ropsten Test Network).

DAI Address on Ropsten = 0xad6d458402f60fd3bd25163575031acdce07538d WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab

in my Wallet i have 2000 DAI (Ropsten)

but when i put the data there. like this: 在此处输入图像描述

Metamask shows that there is an Error thrown by the Contract. So i might be missing something or am'i doing it wrong.

在此处输入图像描述

can please someone help and show me how can i make a successful transaction there?

i got this to work. i someone is interested on the solution, here is what i have done.

1- amountIn should be in 10^18, that means 100 was wrond, it should be 100x10^18 = 100 000000000000000000

2- i had to approve the UniswapRouterAddress to spend this 100 DAI. so on the DAI contract Address i had to put the data like this:

在此处输入图像描述

after that i was able t swipe the 100 DAI for ETH (as much as 100 DAI is worth of ETH)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM