0

I was making a swapping contract where a user could swap tokens using uniswapv2router. I have taken example code from here - https://cryptomarketpool.com/how-to-swap-tokens-on-uniswap-using-a-smart-contract/

I was swapping WETH to doge and getAmountOutMin function gives out min tokens. their contract addresses are:

WETH: 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6

DOGE: 0x962Da63FF7a33875b2D4ed47112ADe44B1Db96E7

However when I tried to swap tokens, it always fails with an error. I have deployed it to Kovan testnet. Any help is appreciated.

Failed transaction is- https://goerli.etherscan.io/tx/0xcbe5bae9b0bd77ae25f2cb900f1d355090d3f1b90c86c9627e609b06ea176864

Smart contract address is: 0x3801e3e49dc73e2a124ea82ec1327068d1b517d9 (Kovan)

1 Answer 1

0

This is probably due to you not passing value to the call to WETH function in order to deposit ETH and get WETH. If you check the traces here you would see that your contract is contacting the WETH contract but not sending any value (value : 0x0).

2
  • So what is the possible solution???? Jun 7 at 5:06
  • and here I am swapping weth not converting eth to weth Jun 7 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.