0

I am trying to get amountsOut quote while swapping the USDT to USDC on polygon mainnet and getting a weird error even after doing the exact things that need to be done

  await window.ethereum.enable();
  const provider = new ethers.providers.Web3Provider(window.ethereum);
  const signer = provider.getSigner();

  const quickswap = new Contract("0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", quickswapabi, signer);

  const path = ["0xc2132d05d31c914a87c6611c10748aeb04b58e8f", "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"];

  const amountIn = ethers.utils.parseUnits("1", 6);

  const amountOut = await quickswap.getAmountsOut(amountIn, path);

While using this code I am getting this error

Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="getAmountsOut(uint256,address[])", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)

I also tried to pass the value as a string and int but still its not working and giving this error

4
  • 1
    Can you add the value of path and quickswap? Best would be to share the whole code.
    – Nal Luksic
    Commented Jun 21, 2023 at 14:29
  • @NalLuksic added full code.
    – Mohit
    Commented Jun 21, 2023 at 14:50
  • is this error given when you execute the transaction, or before you confirm the transaction, so while it tries to understand the gas price for the transaction? Cause I know Polygon has lots of problems with gas price estimation, thus you have to manually specify it
    – 70ny
    Commented Jun 21, 2023 at 20:15
  • 1. Are you sure you are connected to Polygon mainnet? 2. Double-check if quickswapabi is correct. 3. Maybe try calling a view function like WETH() first to see if you have the correct contract instance.
    – Nal Luksic
    Commented Jun 23, 2023 at 8:55

0

Your Answer

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

Browse other questions tagged or ask your own question.