[Ethereum] How to use path (address[]) correctly when interacting with the Uniswap V2 Router

tokensuniswapweb3js

I'm trying to use Uniswap V2: Router 2 https://etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d#writeContract

As a test example I am looking to swap 10 RFI (contract address: 0xa1afffe3f4d611d252010e3eaf6f4d77088b0cd7) for YLD (contract address: 0xdcb01cc464238396e213a6fdd933e36796eaff9f).

I put the amountOutMin number very low so it would go through no matter what. Sadly I don't think I've input the swap route correctly? Any advice would be appreciated.

Writing contract swapExactTokensForTokensSupportingFeeOnTransferTokens

amountIn (uint256)
10000000000000000000

amountOutMin (uint256)
500000000000000

path (address[])
["0xa1afffe3f4d611d252010e3eaf6f4d77088b0cd7", "0xdcb01cc464238396e213a6fdd933e36796eaff9f"]

to (address)
0x[redacted]

deadline (uint256)
1611748800

Error thrown: invalid address (arg="path", coderType="

[![image of the error the contract throws][1]][1]
[1]: https://i.stack.imgur.com/NufKI.png

Best Answer

Are you sure that there's a pool available containing those two tokens? One reason for failure is that a pool doesn't exist for the pair. Another might be that there isn't enough liquidity.

Related Topic