Hi guys, I am making a simple application to buy tokens from by dApp. I am using moralis node API for BSC Testnet. The following is the code for buying the token.
const tokenIn = addresses.WBNB;
const tokenOut = contractAddress;
// console.log("amountIn:", amountIn.toString());
const amounts = await router.getAmountsOut(amountIn, [tokenIn, tokenOut]);
const amountOutMin = amounts[1].sub(amounts[1].mul(slipage).div('100'));
console.log(`
Buying new token
=================
tokenIn: ${ethers.utils.formatEther(amountIn.toString())} ${tokenIn} (WBNB)
tokenOut: ${ethers.utils.formatEther(amountOutMin.toString())} ${tokenOut}
`);
const tx = await router.swapExactETHForTokensSupportingFeeOnTransferTokens(
amountOutMin,
[tokenIn, tokenOut],
addresses.recipient,
Date.now() + deadline,
{ value: amountIn, gasPrice: ethers.utils.parseUnits(gasPrice, 'gwei'), gasLimit: gasLimit }
);
console.log("Transaction hash: " + tx.hash);
const receipt = await tx.wait();
console.log('Transaction Successfull :)');
I Tried to buy and sell the token but I am getting the following error
Error: missing revert data in call exception
(error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":44,\"error\":{\"code\":-32000,\"message\":\"execution reverted\"}}\n","error":{"code":-32000},"requestBody":"{\"method\":\"eth_call\",\"params\":[{\"from\":\"0x466bc559edbbf1b73e06469eaf05a2886ccaa105\",\"to\":\"0xd99d1c33f9fc3444f8101754abc46c52416550d1\",\"data\":\"0xd06ca61f000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd000000000000000000000000783eb71df420d54061ee324828cece18baa211fd\"},\"latest\"],\"id\":44,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://speedy-nodes-nyc.moralis.io/adfsadf/bsc/testnet"}, data="0x",
code=CALL_EXCEPTION, version=providers/5.5.0)
Can anyone help me out with this error?