I am trying to send a transaction using the Etherscan write contract tool at the following address:
https://kovan.etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d#writeContract
The method I wish to use is:
swapExactTokensForToken
And the parameters are:
amountIn: 100000000000000000 (0.1 ETH)
amountOutMin: 1400000000000000000
path: [0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0x25e1474170c4c0aa64fa98123bdc8db49d7802fa]
To: destination address
timestamp: 1602450476
I have tried that, but the transaction fails with an error 'TransferHelper: TRANSFER_FROM_FAILED'.
https://kovan.etherscan.io/tx/0x311805561520f7502befe6e1de6b49e85b9292314ac7a50c0b9fae18c84d8530
I had a look at the code fro TransferHelper.sol but I cannot find the problem.
Can someone explain why this fails?
Best Answer
The error that you're getting implies that you first need to submit from your account the transaction
token.approve(uniswapContractAddress, amountIn)
, wheretoken
is an ERC20 contract at the address indicated bypath[0]
.