Set txfeecap - polygon

Hey guys,

Does anyone know how to set the txfeecap?

I’m on polygon, and got a similar error like this:

[tx fee (2.11 ether) exceeds the configured cap (1.00 ether)]

I’m not sure if there is anything I could do, I found these resources:

https://twitter.com/peter_szilagyi/status/1273163343562510340

1 Like

are you looking to change the default 1.0 ETH, or the tx fee?

If the latter, it may be a setting on Metamask, or on your config file if you are using hardhat.

1 Like

I’m using ethers’ StaticJsonRpcProvider, with the endpoint I received from Pocket Gateway

const POCKET = “https://poly-mainnet.gateway.pokt.network/v1/lb/<API_KEY>”
let ethersProvider = new ethers.providers.StaticJsonRpcProvider(POCKET);

I think I cannot really do anything, I assume this config is at the Pocket server side.

What’s going on here, is that by default, the bor nodes that process Polygon transactions will turn away transactions that use more than a certain amount of gas. The node is forked from go ethereum, where the default behavior is to turn away transactions that use more than 1 ether in gas (I’d assume this is 1 MATIC in your case).

There’s two things that might be happening here:

  1. You’re sending way more gas than you need to be for the transaction. This can happen if you’ve hard coded in a gas value that exceeds this limit.
  2. The transaction that you’re calling to is using more gas than the nodes by default are willing to accept.

In the stack exchange post you mentioned, one of the solutions is to change --rpc.txfeecap on the node side; this is here to make sure that public facing nodes don’t get spammed with transactions that use too much compute. That is a setting that individual node runners have the ability to change if they would like, but it’s safe to assume that nodes are going to be using this value of 1.0 as the default. This is something that Pocket has no control over.

If you could give some more detail about how you’re trying to construct the transaction in ether.js, and what method you’re trying to call on the smart contract, it should be easier to narrow down between the two above scenarios. If it’s 1, that’s something that can be addressed on the ether.js side, and if it’s 2, that’s something that would likely have to be addressed on the EVM/solidity side.

2 Likes

Thanks for the reply.

I think my code works fine and I really need more gasCost than 1 matic.

I’m using paraswap to swap tokens, which can be heavy sometimes, it’s easy to use 1000 000 gas.
With the recent gas price surge on Polygon, gas price can be 1000 gwei ( it’s 500 right now).

In a case like this, gasCost reaches 1 matic.

“that’s something that would likely have to be addressed on the EVM/solidity side.”

I don’t really know what can I do to bypass this problem, I might switch to BSC instead.

1 Like

Given your case, unfortunately there’s not much that you can do to get your transaction through here besides wait for your gasCost to drop below 1 MATIC.

I’ve filed an issue to bring attention to the Polygon devs about the issue you ran into here.

Thanks a lot for your help!

Hey @moltam89 :wave:

As a quick solution, I suggest using Chainstack node endpoints. We set txfeecap to 100 by default.

Thanks, I’ll look into this.

Also want to let you know that the Pocket Network’s backup nodes are also using a sufficient txfeecap as well.