[Ethereum] How to signTransaction on Polygon Matic

polygonweb3js

I have an smart contract running over Ethereum mainnet, Rinkeby, Kovan and BSC.
I am using web3.js to sign transactions in the following way:

var data        = contract.methods.MyFunction(from+'', value+'').encodeABI();
var rawTrx  = {"to": CONTRACT_ADDRESS, "gas": 5000000, "nonce":nonce, "data": data };   

web3js.eth.accounts.signTransaction(rawTrx, SIGN)
.then(signedTx => web3js.eth.sendSignedTransaction(signedTx.rawTransaction))
.then(function(receipt){ return true; })
.catch((err) => { console.log("ERROR 1: " + err); return false;});

I send it by the Polygon RPC URL: https://polygon-rpc.com

It returns several errors indifferently like:

  • ERROR 1: Error: Returned error: tx fee (1.50 ether) exceeds the configured cap (1.00 ether)

  • ERROR 1: Error: Returned error: replacement transaction underpriced

  • ERROR 1: Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!

Any idea why only happend in Polygon Matic network? Works perfectly in the other Ethereum compatible networks.

Best Answer

Seems a problem with the network nonce managment. Remove the nonce from the rawTrx and let the Polygon network assign one.

Related Topic