0

My transactions to swap keep running out of gas and I'm not entirely sure what I'm doing wrong here. I'm generating a quote like below (which is actually a snippet from a 0x repository)

const response = await fetch( ${ZRX_API_URL}/quote?sellToken=${tokenAddressSell}&buyToken=${tokenAddressBuy}&sellAmount=${tokenUnitAmount}${takerAddressString}${skipValidationString}${buyTokenPercentage}, );```

And then feeding this quote to the transaction

txHash = await web3Wrapper.sendTransactionAsync({...swapQuote, from: accountAddress} as Required<SwapQuoteResponse>);

https://etherscan.io/tx/0x58dcfbd6c9e2525b7c578b073284b28acf511fc73e79edf1dc29524312a0fb5a https://etherscan.io/tx/0x4836398a647e509e53afaa1a23c725329f26510fd327fa917587f7c363e339a7 https://etherscan.io/tx/0x9627a2c511266b19014c4abf63399d16cd446975b6d18437c226fe3375b9e28e

Looks like the gas limit is always 280K across all three transactions

Thank in advance

1 Answer 1

1

It's not possible to determine from the code snippet you posted but in 99% of the cases when the gas limit is too low the takerAddress is not correctly passed to 0x API when requesting the quote.

Please verify that you are correctly passing takerAddress=0x.... when requesting the quote, and that the address is the same as the one sending the transaction.

If it still doesn't work, please post the full quote request url with all params.

1
  • Also skipValidationString should be false if you want an accurate estimate Commented Dec 20, 2021 at 22:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.