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