I'm trying to swap BUSD to USDT using pancake swap on the testnet but whenever I try to swap using swapExactTokensForTokens function, I get "execution reverted" error, can you help me find the problem?

contract swaptest{
    address router = 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3;
    address busd = 0x78867BbEeF44f2326bF8DDd1941a4439382EF2A7;
    address usdt = 0x7ef95a0FEE0Dd31b22626fA2e10Ee6A223F8a684;
    address wbnb = 0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd;
    function approve() public {
        IBEP20(0x78867BbEeF44f2326bF8DDd1941a4439382EF2A7).approve(router , 1 ether);
    function swap() public {
        address[] memory path;
        path[0] = busd;
        path[1] = wbnb;
        path[2] = usdt;
        IPancakeRouter02(router).swapExactTokensForTokens( 1 ether , 0 , path , address(this) , block.timestamp );

first I send 2 BUSD to the contract and then I execute approve function and then swap function that is not working. I'm using this website for addresses: https://bsc.kiemtienonline360.com/ .here is the message from remix:

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error.
"code": 3,
"message": "execution reverted",
"data": "0x4e487b710000000000000000000000000000000000000000000000000000000000000032"

and here is transaction hash: 0x180d8f44b3be3e0c06986f69acb2f343f71a9598dad1865caff73c50946c09f3

2 Answers 2


the solution was that I should declare the path variable like this:

address[] memory path = new address[](3);

Mainnet Pancakeswap router on bsc: 0x10ED43C718714eb63d5aA57B78B54704E256024E

busd: 0xe9e7cea3dedca5984780bafc599bd69add087d56

wbnb: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c

usdt: 0x55d398326f99059ff775485246999027b3197955

You are on testnet, my mistake.

I don't have access to your BUSD. But the factory contract does show a pool for it for you to swap through.

I did just test a couple of swaps using the addresses you have, for router and WBNB and they work. https://testnet.bscscan.com/tx/0xda779fc16026d3429537b3f923b1714e8ed8f431cf86fb3c4fe710e2b3f549d7

I would try different routes and makes sure it's not a remix error by clearing cookies and pulling up the contract again, or trying through something like brownie.

  • i'm working on bsc testnet and here is tx hash and remix message
    – Meysam
    Oct 5, 2022 at 8:55
  • Ah testnet, my mistake.
    – Maka
    Oct 5, 2022 at 8:56

Your Answer

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

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