1

I'm trying to buy tokens and I'm getting an error and failed transaction. It's taking the gas fee and then failing. I've attached the contract and the errors from etherscan and error from terminal. enter image description here enter image description here enter image description here enter image description here

If someone can guide me in the right direction I'd be very grateful, at this a few days now and hitting brick wall after brick wall - surely it's a simple mistake I'm making and a simple fix. Thanks

1

If this is the EatTheBlocks bot.js code, then I think you're missing an approve() call, which his code doesn't have.

swapExactTokensForTokens() calls transferFrom(), which can't be called without a prior approval.

If you look at his equivalent PancakeSwap bot, the code includes an approve():

const init = async () => {
  const tx = await wbnb.approve(
    router.address, 
    'replace by amount covering several trades'
  );
  const receipt = await tx.wait(); 
  console.log('Transaction receipt');
  console.log(receipt);
}

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.