CRYPTO NEWS

Uniswap/PancakeSwap function swapExactTokensForETH produce error

I have code to call pancakeswap/uniswap router function to swap token. In my code, I have no problem calling swapExactETHforTokens when swapping WBNB to BUSD in BSC. my problem came when I tried calling swapExactTokensForETH function to swap BUSD to WBNB. It showed me this error

Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"cannot estimate gas; transaction may fail or may require manual gas limit","code":"UNPREDICTABLE_GAS_LIMIT","error":{"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc":"2.0","id":817,"error":{"code":3,"message":"execution reverted: TransferHelper: TRANSFER_FROM_FAILED","data":"0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000245472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c454400000000000000000000000000000000000000000000000000000000"}}n","error":{"code":3,"data":"0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000245472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c454400000000000000000000000000000000000000000000000000000000"},"requestBody":"{"method":"eth_estimateGas","params":[{"gasPrice":"0x2540be400","type":"0x0","from":"0xa715c85973f8e0282ee8c1fc36305be23928344f","to":"0xd99d1c33f9fc3444f8101754abc46c52416550d1","data":"0x18cbafe5000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000713d616652258ed00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000a715c85973f8e0282ee8c1fc36305be23928344f0000000000000000000000000000000000000000000000000000000060e5bd9a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000078867bbeef44f2326bf8ddd1941a4439382ef2a7000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd"}],"id":817,"jsonrpc":"2.0"}","requestMethod":"POST","url":"https://data-seed-prebsc-1-s1.binance.org:8545"},"method":"estimateGas","transaction":{"from":"0xA715c85973f8E0282eE8c1FC36305bE23928344f","gasPrice":{"type":"BigNumber","hex":"0x02540be400"},"to":"0xD99D1c33F9fC3444f8101754aBC46c52416550D1","data":"0x18cbafe5000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000713d616652258ed00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000a715c85973f8e0282ee8c1fc36305be23928344f0000000000000000000000000000000000000000000000000000000060e5bd9a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000078867bbeef44f2326bf8ddd1941a4439382ef2a7000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd","type":0,"accessList":null}}, tx={"data":"0x18cbafe5000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000713d616652258ed00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000a715c85973f8e0282ee8c1fc36305be23928344f0000000000000000000000000000000000000000000000000000000060e5bd9a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000078867bbeef44f2326bf8ddd1941a4439382ef2a7000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd","to":{},"from":"0xA715c85973f8E0282eE8c1FC36305bE23928344f","gasPrice":{"type":"BigNumber","hex":"0x02540be400"},"type":0,"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.4.0)

from the error i believe it is because it is unable to estimate gas. but I was wondering why would it not be a problem in swapExactETHforTokens function?

If the problem is estimating gas, what should I add in the code? I used PancakeSwap/sdk in the code as well.

down here is the piece of code that execute the swap. hope it makes the context a little bit clearer

const swap = async () => { try {   error = '';   console.log(`Swap process`);   console.log({ tokenFrom, tokenTo });    const wallet = new ethers.Wallet($settings.privateKey, binance().bsc);   const account = wallet.connect(binance().bsc);    var amountOutMin = trade.minimumAmountOut(slippageTolerance).raw;   amountOutMin = BigNumber.from(amountOutMin.toString());   const path = [token0.address, token1.address];   const to = account.address;   const deadline = Math.floor(Date.now() / 1000) + 60 * 20;   var amountIn = trade.inputAmount.raw;   console.log(amountIn);   //var amount1 = amountIn*100000000000000000;   amountIn = BigNumber.from(amountIn.toString());   console.log({ amountIn, amountOutMin });    const uniswap = new ethers.Contract(     '0xD99D1c33F9fC3444f8101754aBC46c52416550D1',     [       'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',       'function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',       'function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',     ],     account   );    var tx;   if (token0.address === WETH[chainId].address) {     console.log(`Swap exact ETH for tokens`)     tx = await uniswap.swapExactETHForTokens(       amountOutMin,       path,       to,       deadline,       { value: amountIn }     );   } else if (token1.address === WETH[chainId].address) {     console.log(`Swap exact tokens for ETH`)     tx = await uniswap.swapExactTokensForETH(       amountIn,      //maybe in 18 decimal       amountOutMin,    //need to get getamountout by calling getamountout       path,       to,       deadline,     );   } else {     console.log(`Swap exact tokens for tokens`)     tx = await uniswap.swapExactTokensForTokens(       amountIn,       amountOutMin,       path,       to,       deadline     );   }   console.log(`Transaction hash: ${tx.hash}`);    const receipt = await tx.wait();   console.log(`Transaction was mined in block ${receipt.blockNumber}`); } catch (error) {   console.error(error);   error = error.message; } 

};

FBI Adds OneCoin Founder Ruja Ignatova ‘Crypto Queen’ to Its Top 10 Most Wanted List

OneCoin founder Ruja Ignatova, also known as “Cryptoqueen,” was added to the list of the FBI’s Ten Most Wanted Fugitives for her role in allegedly defrauding investors of more than $4 billion. This action was taken by the FBI in New York, along with the United States Attorney’s Office in the Southern District of New York and::Listen

OneCoin founder Ruja Ignatova, also known as “Cryptoqueen,” was added to the list of the FBI’s Ten Most Wanted Fugitives for her role in allegedly defrauding investors of more than $4 billion.

This action was taken by the FBI in New York, along with the United States Attorney’s Office in the Southern District of New York and the IRS Criminal Investigation Newark Field Office. The Federal Bureau of Investigation also offered a reward of up to $100,000 for information that would lead to her capture.

Indicted by a federal grand jury in October 2017, a warrant for Ignatova’s arrest was issued by the United States District Court for the Southern District of New York at that time. Ignatova was charged with one count of conspiracy to commit wire fraud, one count of wire fraud, one count of conspiracy to commit money laundering, one count of securities fraud, and one count of conspiracy to commit securities fraud in a superseding indictment that was handed down in February of 2018.

According to investigators, Ignatova is suspected of being involved in a fraudulent operation of significant scope. It is believed that Ignatova and others began defrauding investors around 2014. The amount of money involved is estimated to be in the billions of dollars.

She was the brains behind the project that would later become known as OneCoin Ltd., located in Bulgaria, and promoted a product that claimed to be a cryptocurrency. Allegedly, to put the plan into motion, Ignatova engaged in deceptive behavior toward people by making false claims and representations to them about OneCoin investment opportunities. 

Ignatova reportedly urged victims to move investment amounts to OneCoin accounts to acquire OneCoin packages, resulting in victims sending wire transfers reflecting their investments. She is accused of engaging in this fraudulent activity. Throughout the conspiracy, it is suspected that victims lost more than $4 billion due to fraud committed by OneCoin. Ignatova was OneCoin’s top leader until October 2017, when she stepped down.

In March 2019, Ignatova was arrested in the USA for allegedly running a pyramid scheme. In May of the same year, the OneCoin founder was sued by a former investor over an alleged multi-billion dollar fraud.

In May 2022, the OneCoin founder was declared wanted in Europe by the International Criminal Police Organization (Interpol) for fraud and money laundering.

The post FBI Adds OneCoin Founder Ruja Ignatova ‘Crypto Queen’ to Its Top 10 Most Wanted List appeared first on CryptoSlate.

Uniswap/PancakeSwap function swapExactTokensForETH produce error

Shopping cart
There are no products in the cart!
Continue shopping
0