I forked SAFEMOON a few times but I’m having the same issue over and over. FYI I have the PancakeSwap Router v2 hardcoded into the contract the the problem should not stem from that.

Essentially, when I add LP, people can trade the token freely and everything works. However when I try to remove from the LP (or if anyone tries to add more to the LP), the token stops working. This means nobody can withdraw LP, or trade the token. LP withdrawal gets stuck as the “Confirm” button on the final stage doesn’t do anything, and swaps are met with:

“The transaction cannot succeed due to error: TransferHelper: TRANSFER_FROM_FAILED. This is probably an issue with one of the tokens you are swapping.”

After calling setSwapAndLiquify(false) on the contract, it is possible to withdraw from the LP and the token is able to be swapped (however, this literally removes the automatic 5% LP tax which is counterproductive). Setting it to true again throws the same errors as previously.

I’ve tried numerous contracts with different size LP pools etc, but the error is the same constantly.

Me removing LP: https://bscscan.com/token/0x6160bC4714245B7e5a2c5AE10a147680b2EB9Ec0

My friend adding LP: https://bscscan.com/token/0x045A44103A89D9CEB73B3EA9c02cE5fEd5c273d7

I honestly cannot figure out why this may be happening and can’t run the risk of someone else adding liquidity to the token and stopping it from working.

Thank you in advance

2 Answers 2


The address you have hard coded in is PanCakeSwap V1. You can check it here: https://bscscan.com/address/0x05ff2b0db69458a0750badebc4f9e13add608c7f The Address for PanCakeSwap V2 is https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e

You are using Uniswap V2 code, but Pancakeswap is a clone of Uniswap so the code works, but the address is wrong.

Because your address is hard coded in you will not be able to change it. And since migration from V1 to V2 on Pancakeswap you can't make a new LP on V1. So your swapandliquify function is trying to create an LP pool on V1 and it cannot so the swap will fail. This is why when you set to false people can trade, because now it is not trying to communicate with the V1 LP that does not exist.

This is what I've been able to uncover having stubbled into this problem myself, but I am new to solidity, so I may be missing something. I made this video about this problem: https://youtu.be/td_NXJ8k4Uc

When I made the video I did not know the V2 address, I have not yet tried to deploy a contract using the V2 address. I found it while writing this reply.

Good luck!

  • I just found this token on Poocoin. You can see that they have LP on V2 but V1 is empty. When you check on the contract they have hard coded the V2 Pancakeswap address that I gave in my previous comment. I have been trying to deploy this contract to the test network but I can not get it to deploy. poocoin.app/tokens/0x69b2f663d311c0743ec6fd40bea04f31bd9704b6 I also found some information on DXSale that suggests changes to make in order to deploy. I made the changes but it still did not work for me. (see the very bottom of this page): docs.dxsale.network/faq May 7, 2021 at 15:38
  • 1
    This actually resolved a development error for me, thanks. I was using the router code that is linked to SafeMoon but it never worked. changing for the v2 contract fixed it.
    – riordant
    May 26, 2021 at 10:44

At the "approve" prompt, try choosing 'Receive WBNB' instead of BNB. That works for me even when my setSwapAndLiquify is still (true).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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