I am creating a bot to buy and sell tokens on Uniswap through a smart contract. The buying part goes on well I buy the tokens uisng the smart contract I have deployed. But when it comes to selling, I have to send the tokens from my wallet to the smart contract then sell them. All this should happen in the smart contract. I use transferfrom and approve to make it possible to sell but the approve never works so I always get an error that I am trying to sell more tokens than I had approved.

Aug 30, 2021, 7:32 AM
This is an example of what I am trying to achieve

https://cryptomarketpool.com/how-to-swap-tokens-on-uniswap-using-a-smart-contract/
Aug 30, 2021, 7:32 AM
You need two approvals to make that possible. First one for your contract to take token from msg.sender, and next one for router to take token from contract.
Aug 30, 2021, 7:51 AM
This makes sense . Let me try it out
Aug 30, 2021, 7:53 AM

© 2024 Draquery.com All rights reserved.