I am quite new to solidity, and I just created my first bep20 token. However, I am trying to implement a sell and buy tax using pancakeswap v2 router but I haven't been able to figure out how to implement this as the pancakeswap documentation is weak when it comes to being beginner-friendly.

Please I'd appreciate any help with this, and possibly how I can test it on testnet.

  • I am not really sure abotu what you want to implement as a tax. But I would change the _transfer() function to write the tax here and take the tax from here to put it in the wallet of your choice. I am not 100% sure how that would work with pancake swap though
    – Cizia
    Oct 16 '21 at 6:08

The Pancakeswap router only handles trades, it does not handle taxes and other special functionality.

As mentioned in the comments, you have to implement such custom functionality in transfer and transferFrom functions. So, for example, if user wants to transfer 100 tokens to account B, your transfer functionality takes 100 from the sender, assings 99 to the receiver and keeps 1 as tax.

  • Thanks for the clarity @Lauri. But, if I may ask, how can one know when a user is selling the token or buying it?
    – David
    Oct 17 '21 at 13:36

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.